so i been giving a list with numbers, I need to grab the odd numbers from the list and sum them, the problem is that I need to only grab the first 5 odd numbers from the list on a while loop, this is what i came up with:
num_list = [422, 136, 524, 85, 96, 719, 85, 92, 10, 17, 312, 542, 87, 23, 86, 191, 116, 35, 173, 45, 149, 59, 84, 69 , 113, 166]
runs = 0
odd = []
while runs <=5:
for i in num_list:
if i % 2 == 1:
odd.append(i)
runs += 1
print(odd)
the code runs but my counter is not working, it appends all the odd numbers instead of the first 5 it finds on the iteration, what is wrong here?
EDIT: thank you all for the answers, It would be easier to do it without the while loop but they asked me to use the while loop.