''Essentially, you must design a Python program that prompts a user for a year, a day of the year (an integer between 1 and either 365 or 366 to account for leap year), and output the month, day, and year.
For example, give the year 2018, and the day 335, your Python program would return December 1, 2018.''
I've been trying to use if statements to solve this. However, somehow the code works up until day 62 (March), and stops working after that (printing nothing at all). I'm not sure what is going on as my code is very similar each month.
full_month = 31
if day <= full_month:
print('January')
elif full_month <= day <= (full_month + 29):
print('February')
etc...
Aucun commentaire:
Enregistrer un commentaire