$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #211

Which fix removes the bug?

from datetime import datetime
d = datetime.strptime('2026-10-11', '%Y-%d-%m')
print(d.month)  # expected 10
  1. Use the format '%Y-%m-%d'
  2. Use the format '%y-%m-%d'
  3. Call d.day instead here
  4. Parse it with int() first
The format swaps day and month, so the date silently parses as 10 November.
Play Problem Solving ▸