In the starting code, you'll find the solution from the Leap Year challenge. First, convert this function is_leap()
so that instead of printing "Leap year." or "Not leap year." it should return True
if it is a leap year and return False
if it is not a leap year.
You are then going to create a function called days_in_month()
which will take a year and a month as inputs, e.g.
days_in_month(year=2022, month=2)
And it will use this information to work out the number of days in the month, then return that as the output, e.g.:
28
The List month_days contains the number of days in a month from January to December for a non-leap year. A leap year has 29 days in February.
-
Look at the function call at the bottom of the code to see the positional arguments. The order is very important.
-
Feel free to choose your own parameter names.
-
Remember that
month_days
is a List and Lists in Python start at position 0. So the number of days in January ismonth_days[0]
-
Be careful with indentation.
Before checking the solution, try copy-pasting your code into this repl:
https://repl.it/@appbrewery/day-10-1-test-your-code
This repl includes my testing code that will check if your code meets this assignment's objectives.