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/FoolsSeldom Sep 02 '25
if(odd_numbers % 2 == 0)is not valid:odd_numbersreferences alistobject, and you cannot apply the modulo,%, operatorMissing a
:from the endMissing an indented statement under the
ifIf you want to check the
listcontains only odd numbers and there are 10 of them, you can use: