In this article, you will learn how to calculate the number of days between 2 dates in Python.
At the beginning, import
from datetime import date
Then, define the first and second date
first_date = date(2021, 1, 31) second_date = date(2021, 2, 28)
difference = second_date - first_date
At the end, print
print(difference.days) # 28