0
please someone explain me!!!
evens = [i**2 for I in range (10) if i**2 % 2 == 0] print(evens) what does if statement really do in above code? Thanks....
2 Answers
+ 2
if will take from range(10) only numbers that match condition i*i%2==0 (their sqare is even). without that if part you would get squares of numbers 0 to 9, but with if you get even squares of numbers 0 to 9.
- 1
the if statement is wrong you must delete it.