DEV Community

loading...

How to remove the first character of a string in Python?

Murtaja Ziad
A Full-Stack Web Developer.
Originally published at blog.murtajaziad.xyz on ・1 min read

You can remove the first character of a string using Python easily by removing the first index of the string.

string = "abcdef"
print(string[1:]) # bcdef
Enter fullscreen mode Exit fullscreen mode

[1:] means get the string starting from index 1 to the end. Also, you can use it with any index using this syntax: string[start:stop].

Discussion (0)