Python remove first character | Example code

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.1.3 (Community Edition)

Windows 10

Python 3.7

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


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.