Search code examples
pythonstringintegerstrip

Python - Remove first three chars' of string


So I have a super long string composed of integers and I am trying to extract and remove the first three numbers in the string, and I have been using the lstrip method (the idea is kinda like pop) but sometimes it would remove more than three.

x="49008410..."
x.lstrip(x[0:3])
"8410..."

I was hoping it would just remove 490 and return 08410 but it's being stubborn -_- .

Also I am running Python 2.7 on Windows... And don't ask why the integers are strings. If that bothers you, just replace them with letters. Same thing! LOL


Solution

  • Instead of remove the first 3 numbers, get all numbers behind the third position. You can do it using : operator.

    x="49008410..."
    x[3:]
    >> "8410..."