livepython.net

167. Python Program to Find the Number of Days Between Two Dates

Easydatetime

Overview

Let Python count the days, leap years and all.

Problem Statement

Read two dates, one per line, written as YYYY-MM-DD. Print how many days there are between them. The second date may be earlier than the first; the answer is never negative. For example, for 2025-03-14 and 2026-01-01:

Days between: 293

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

Two dates, one per line. Example:

2025-03-14
2026-01-01

Output

The output for that example:

Days between: 293

The tests try 4 different inputs.

Learn this firstChapter 18 · Python datetime Module: Dates, timedelta and strftime
solution.py
# write your code here

EXPECTED OUTPUT

1Days between: 293

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.