Skip to content

Python remove first character | Example code

  • by

Use the slice method to remove the first character in Python. Here’s how the code would look like:

text = 'lipsum'
print(text[1:])

Output:

Python remove first character

Removing the first x characters from a string in Python

Use string slicing syntax string[n:] with n as the number of characters to remove the first n characters from a string.

Example removing the first 3 char from the given string.

text = 'lipsum'
print(text[3:])

Output: sum

Do comment if you have any doubts and suggestions on this Python char code.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading