practicepython.in
python exercises
171 exercises

Daily #36 · 3 November 2026

Two endings at once Medium

What does this print?

file = "notes.txt"
print(file.endswith((".txt", ".md")))
  1. AFalse
  2. Braises TypeError
  3. C.txt
  4. DTrue
Show the answer

D: True

Why: startswith and endswith accept a tuple and return True if any one of them matches. It must be a tuple: a list raises TypeError.

Play today’s puzzle →