I think this has wrong answer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I think this has wrong answer?

for i in range(10): if not i%2 == 0: print(i) The answer here is that it will print all even numbers between 2 and 10 but actually it prints odd numbers between 1 to 9.

22nd May 2019, 12:29 PM
Manav Sharma
Manav Sharma - avatar
1 Answer
+ 2
basically, i%2 == 0 - all even numbers not i%2 == 0 - tries to find numbers that are NOT even.
22nd May 2019, 1:17 PM
Choe
Choe - avatar