The Next Day
Advanced · Stretch · from Python If-Else: Conditions, Elif, Nested Ifs, and Ternary
From the lesson: Python If-Else: Conditions, Elif, Nested Ifs, and Ternary
Every day you make hundreds of decisions. If it's raining, you grab an umbrella. If the traffic light is red, you stop. If your phone battery is below 20%, you look for a charger. These are all conditional decisions - you check something and act based on the result.
Read the lessonWrite a function next_day(day, month, year) that returns the date of the following day as text in the form "YYYY-MM-DD".
next_day(14, 3, 2026) # '2026-03-15'
next_day(30, 4, 2026) # '2026-05-01'The rules of the calendar:
Return the answer instead of printing it: Check calls next_day() with its own dates, some of them hidden.
What Check runs
Your code runs first, then each of these lines, and 5 more that stay hidden. The output must match exactly.
| Runs | Expected output |
|---|---|
| next_day(14, 3, 2026) | '2026-03-15' |
| next_day(30, 4, 2026) | '2026-05-01' |
More If-Else exercises
- Even or OddBeginner
- Temperature AdvisorBeginner
- Predict the OutputBeginner
- Fix the Grade CalculatorBeginner
- Ternary Ticket PriceBeginner
- Login ValidatorBeginner
All Python exercises · 50 practice problems · Control Flow quiz