Python while loop is running even though conditions aren't met

Viewed 17

The month is 5, but the while loop that runs while the month is 4 seems to run every time. I have no idea how to fix this. Are the multiple ors causing problems?

dateMonth = 5
dateDay = 31

while dateMonth == 4 or 6 or 9 or 11:
  if dateDay > 30 or dateDay < 1:
    print("That date is is invalid. There are only 30 days in this month")
    break
  else:
    break

while dateMonth == 1 or 3 or 5 or 7 or 8 or 10 or 12:
  if dateDay > 31 or dateDay < 1:
    print("That date is invalid. There are only 31 days in this month.")
    break
  else:
    break
0 Answers
Related