Thats odd.. code coach | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Thats odd.. code coach

Why does this code not work numbers = int(input()) all = [numbers] for i in range (numbers): numb = int(input()) all.append(numb) #print(all) even = [] for j in range(numbers): if all[j] % 2 == 0: even.append(all[j]) #print(even) total = 0 for k in range(len(even)): total = even[k] + total print(total)

20th Mar 2021, 4:41 PM
Ash 07
Ash 07 - avatar
2 Answers
+ 1
you must initialize your 'all' list with an empty list (as you do for 'even' list): all = [ ]
20th Mar 2021, 4:46 PM
visph
visph - avatar
+ 1
Thanks, i didnt read the questions properly😅
20th Mar 2021, 7:27 PM
Ash 07
Ash 07 - avatar