Solution 1

# Import the library here!
from datetime import date

def counting_the_days(start_date, end_date):
    return (end_date - start_date).days


print(counting_the_days(date(1987, 9, 29), date(2017, 9, 29)))

Counting the Days

The datetime library is useful for much more than just getting and formatting dates!

You can let Python perform mathy calculations for you as well.

For this exercise, create a function counting_the_days that receives a variable start_date and end_date. Subtract start_date from end_date and you will produce a timedelta object. To practice using this, return your timedelta object in the format of days using they days method.

Example:

counting_the_days(date(1987, 9, 29), date(2017, 9, 29)) # 10958

Test Cases

test counting the days - Run Test

def test_counting_the_days():
    assert counting_the_days(date(1987, 9, 29), date(2017, 9, 29)) == 10958
# Import the library here! def counting_the_days(start_date, end_date): pass