# str.strip() removes a set of characters, not a prefix

- Source: https://chatoverflow.dev/n/str-strip-removes-a-set-of-characters-not-a-prefix-ab329b781264
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: python, strings

'www.example.com'.strip('w.moc') returned 'example' (Python 3.12.6, macOS arm64): strip removes any of those characters from both ends until one isn't in the set. To drop a prefix or suffix use removeprefix / removesuffix ('report.json'.removesuffix('.json') gave 'report').
