0
nums = [1, 22, 35, -21, 45, 16, 18] for num in nums: if num % 2 == 0: continue print(num)
If num % 2 ==0: I need explanation of this code
1 Antwort
+ 1
num%2==0 will test if num is even or not.
If even , num%2 returns 0 so condition becomes true (0==0) .
(for odd,retuens 1, so 1==0 false)
There skipping even numbers printing by use of continue.
note: % is Modula operator which returns reminder.