l = list((12, 2, 30, 4, 50))
for x in l:
if x % 2 == 0:
continue
else:
print("The list contains an odd number")
break
else:
print("The list contains no odd number")
Here, the for loop will iterate over all the numbers of the list. If a number is odd, the program will print “The list contains an odd number” and come out of the loop. After iterating over all the numbers of the list, if no odd number is found, then the else part of the for loop will be executed and the program will print “The list contains no odd number”
The above program will print the following output:
The list contains no odd number








































0 Comments