string removeprefix str.removeprefix() and str.removesuffix() added in Python 3.9. Cleaner than slicing. 'test_file.py'.removeprefix('test_') # 'file.py' Learned on 2025-05-19