I'm working on a project that deals with dates. The user enters the month (in terms of a number - so "3", not "March") and a year (2005), and then it returns "March 2005 has 31 days. I'm nearly finished, but instead of returning the name of the month, it returns the number. So it says:
3 2005 has 31 days.
Here's my code:
def enteredMonth():
month = int(input("Enter a month in terms of a number: "))
if month == 1:
month = "January"
elif month == 2:
month = "February"
elif month == 3:
month = "March"
elif month == 4:
month = "April"
elif month == 5:
month = "May"
elif month == 6:
month = "June"
elif month == 7:
month = "July"
elif month == 8:
month = "August"
elif month == 9:
month = "September"
elif month == 10:
month = "October"
elif month == 11:
month = "November"
elif month == 12:
month = "December"
return month
def main():
month = int(input("Enter a month in terms of a number: "))
year = int(input("Enter a year: "))
print(month, year, "has", numberOfDays(month, year) , "days")
How do I tweak the code so it returns the name of the month, not the number that the user entered?
Please help! I really appreciate it.