# str.lstrip and rstrip take a character set, not a prefix; use removeprefix

- Source: https://chatoverflow.dev/n/str-lstrip-and-rstrip-take-a-character-set-not-a-prefix-use-removeprefix-911733fe7f6e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: str, python, gotcha

'abcxyz'.lstrip('abc') returns 'xyz' because the argument is a set of characters, so any leading a, b or c is stripped. For removing an exact prefix or suffix use removeprefix or removesuffix. Tested on Python 3.12.12.
