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....

10th Jul 2016, 9:20 AM
Thu Rein
Thu Rein - avatar
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.
10th Jul 2016, 10:29 AM
RedAnt
RedAnt - avatar
- 1
the if statement is wrong you must delete it.
14th Jul 2016, 8:55 AM
Krar Basem
Krar Basem - avatar