How to print the season name of the year based on the month number in Python

1 Answer

0 votes
def print_season(month):
    # Determine the season based on the month number
    if month in (12, 1, 2):
        print("Winter")
    elif month in (3, 4, 5):
        print("Spring")
    elif month in (6, 7, 8):
        print("Summer")
    elif month in (9, 10, 11):
        print("Autumn")
    else:
        print("Invalid month number!")


month = 9

print_season(month)



"""
run:

Autumn

"""

 



answered Sep 10 by avibootz
edited Sep 10 by avibootz
...