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

26th Jun 2021, 12:37 PM
Md Nazim Uddin Sagor
Md Nazim Uddin Sagor - avatar
1 Answer
+ 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.
26th Jun 2021, 12:40 PM
Jayakrishna 🇼🇳