$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #238

Which fix removes the bug?

name = 'report.txt'.strip('.txt')
print(name)  # expected report
  1. Use rstrip('.txt') instead
  2. Use removesuffix('.txt')
  3. Use lstrip('.txt') instead
  4. Use split('.txt')[1] here
strip removes any of the characters . t x from both ends, eating the final t of 'report' too.
Play Problem Solving ▸