btw thanks you very much, Mr Derek and all

yes that is exercise basic in python, i'm newbie in python and i hope learn
djanggo, before i have try code looping

lst = []

# number of elemetns as input
n = int(input("Enter number of elements : "))

# iterating till the range
for i in range(0, n):
    ele = int(input())

    lst.append(ele) # adding the element

print(lst)

test_list1 = []
n2 = int(input("Enter number of elements2 : "))

for i2 in range(0, n2):
    ele2 = int(input())

    test_list1.append(ele2) # adding the element

print(test_list1)

res_list = [lst[i] + test_list1[i2] for i in range(len(lst))]

print(res_list)


but still wrong, about exercise in below , how if without

*1) def elementswise_left_join(l1, l2) and *
*2) def get_array(n):*

can someone give me again ? thanks very much

the exercise same, in below here :

1 ) input: 3 , return [1, 2, 3]
then continue dynamic

2) input: 2, return [2, 4, 3]
  then continue dynamic

3) input: 6, return [3, 6, 6, 4, 5, 6]
  then continue dynamic

4) input: 1, return [4, 6, 6, 4, 5, 6]
  then continue dynamic

5) input: 1, return [5, 6, 6, 4, 5, 6]

thanks








Pada tanggal Sen, 31 Mei 2021 pukul 20.41 Derek <[email protected]>
menulis:

> This does look a programming exercise in a class...  if you ask these
> questions in future, be warned people here will probably ask to see your
> attempt at writing code first (otherwise you are not really learning to be
> a programmer).
>
> But, OK, it seemed interesting to me,so here is one approach:
>
> def elementswise_left_join(l1, l2):
>     """
> https://www.w3resource.com/python-exercises/list/python-data-type-list-exercise-155.php
> """
>     f_len = len(l1) - (len(l2) - 1)
>     for i in range(0, len(l2), 1):
>         if f_len - i > len(l1):
>             break
>         else:
>             l1[i] = l1[i] + l2[i]
>     return l1
>
>
> def get_array(n):
>     if n == 1:
>         return [1,]
>     r = [x for x in range(1, n + 1)]
>     return r
>
>
> curr = []
> valid = True
> while valid:
>     num = input("Enter number: ")
>     if num:
>         new = get_array(int(num))
>         if len(new) > len(curr):
>             curr = elementswise_left_join(new, curr)
>         else:
>             curr = elementswise_left_join(curr, new)
>         print(curr)
>     else:
>         valid = False
>
>
>
> On Monday, 31 May 2021 at 13:34:51 UTC+2 [email protected] wrote:
>
>> how about if input like in below
>> 1 ) input: 3 , return [1, 2, 3]
>> then continue dynamic
>>
>> 2) input: 2, return [2, 4, 3]
>>   then continue dynamic
>>
>> 3) input: 6, return [3, 6, 6, 4, 5, 6]
>>   then continue dynamic
>>
>> 4) input: 1, return [4, 6, 6, 4, 5, 6]
>>   then continue dynamic
>>
>> 5) input: 1, return [5, 6, 6, 4, 5, 6]
>>
>> thanks
>>
>>
>> Pada tanggal Sen, 31 Mei 2021 pukul 18.20 paidjoo indo <[email protected]>
>> menulis:
>>
>>> hello i having question, because i still learn python for me, so can
>>> help me
>>> the question is
>>>
>>> how about if input like in below
>>> 1 ) input: 3 , return [1, 2, 3]
>>>
>>> 2) input: 2, return [2, 4, 3]
>>>
>>> 3) input: 6, return [3, 6, 6, 4, 5, 6]
>>>
>>> 4) input: 1, return [4, 6, 6, 4, 5, 6]
>>>
>>> 5) input: 1, return [5, 6, 6, 4, 5, 6]
>>>
>>> thanks in advance
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3a5ee884-4d66-4fc3-8217-64658d7f585dn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3a5ee884-4d66-4fc3-8217-64658d7f585dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO%3D2VJmK397LRF3%2BBCDXLg8OyxRYMcwzyndpxibb0MGZLF4jdw%40mail.gmail.com.

Reply via email to