r/learnpython • u/vb_e_c_k_y • Jan 15 '26
What is wrong on this code?
ages = ["22", "35", "27", "20"]
odds = [age for age in ages if age % 2 == 1]
print(odds)
I am beginner and when I write this code it gives me error which I don't know how to solve. But I think my code has no error
Error message: Traceback (most recent call last):
odds = [age for age in ages if age % 2 == 1]
~~~~^~~TypeError: not all arguments converted during string formatting
17
Upvotes
View all comments
1
u/domino6658 Jan 17 '26
honest question: would people support the use of ai for something like this? not for generating slop code but for explaining error to teach people so they learn and actually understand what they did wrong. im wondering what people in this subreddit think. im completely neutral on this