Python Example - Get and remove First Character from a String

This tutorial explains about following examples in Python

  • How to get First character from a String in Python
  • Remove First and beginning character from a string in python

Python get First Character from a string

First character can be get using index=0,hence str[0] results to first character

Here is an example


print(str[0]); #h

Remove First Character from a string in python

Many ways we can remove the First character, return new string

One way by using slicing syntax

str[1:] return all characters except first character

Second way using lstrip function

lstrip removes the first character from a string and return a new string



result = str.lstrip(str[0])
print(result); #ello