Skip to main content
  1. Posts/

Find Number of Days in a Month

·64 words·1 min

Hello here is the code on how to find the numbers of days in a month.

month_with_31_days = ("January", "March", "May", "July", "August", "October", "December")
month_with_30_days = ("April", "June", "September", "November")
month_with_28_days = ("February")

month = 'February'

if month in month_with_31_days:
    total_days = 31
elif month in month_with_30_days:
    total_days = 30  
else:
    total_days = 28

print(f"{ month } has {total_days} days")

Thank You :3