r/PythonLearning • u/Hunter_z39 • Sep 02 '25
Help Request HELP ME
why is this code is not working
'''
Task 3 — Odd numbers 1–19
Make a list of odd numbers from 1 to 19 (use a step).
Self-check: 10 numbers, all odd.
'''
odd_numbers = []
for value in range(1, 20, 2):
# Using step of 2 to get odd numb
odd_numbers.append(value)
if(odd_numbers % 2 == 0)
print(odd_numbers)
0
Upvotes
1
u/SpecialistTicket1 Sep 02 '25
So there are couple of mistakes.
You have to check value%2==0 instead ‘odd_numbers’ list.
If value % 2==0 is true, then you need to append that value to the empty list which you have created: odd_numbers.append(value)
At last you can print the list outside for loop.