# Find the anomaly month in the list below
days = [30, 31, 30, 30, 31, 30, 20, 30, 31, 30, 31, 30]
for day in days:
if not(day == 30 or day == 31):
break
else:
print(day)
In your code, instead of break it should have been pass, as former would break control out of the for loop before all values have been checked.
You can have a look at my code to get a better understanding.
Here, I am checking if i equals to either 30 or 31. If yes, nothing happens, otherwise the value is printed.
# Find the anomaly month in the list below
days = [30, 31, 30, 30, 31, 30, 20, 30, 31, 30, 31, 30]
for i in days:
if((i==30)or(i==31)):
pass
else:
print(i)