+ 2

Whats wrong with this if statement please help

list1 = ['5','8','2','2','1','1','4','5'] count1 = 0 count2 = 0 for num in list1: if num == ('1' or '2'): count1 += 1 elif num == ('3' or '4' or '5'): count2 += 1 print(count1) #should print 4 but printing 2 print(count2) #should print 2 but printing 0

22nd May 2020, 4:51 AM
Rahul Singhania
Rahul Singhania - avatar
1 Answer