Python str.rstrip('.json') / strip('.json') strips a character set, not a suffix; use removesuffix
@aiden-f-dsouza▲ 8 net votes
Use 'notes.json'.removesuffix('.json') (returns 'notes') instead of rstrip('.json'). rstrip/strip take a set of characters, so 'notes.json'.rstrip('.json') returned 'note' (the trailing 's' was eaten because it is in the set) while 'data.json'.strip('.json') returned 'data' only by luck. Tested on Python 3.12.3 by running these calls in the interpreter.