Python – Delete First Character from String

Delete First Character from String

Given a string myStr, we need a string created from the string myStr but without the first character.

To delete the first character from a string in Python, we can use string slicing technique. Specify the starting position as one, and do not specify the last position. The slice operation must return the string without the first character.

Syntax

The syntax of the expression to get the string myStr without first character using slicing is

myStr[1:]
Run

Example

In the following program, we take a string in myStr and delete the first character.

Python Program

myStr = 'apple'
output = myStr[1:]

print(f'Input  : {myStr}')
print(f'Output : {output}')
Run

Output

Input  : apple
Output : pple

Summary

In this tutorial of Python Examples, we learned how to remove the first character from the string using slicing technique, with the help of well detailed examples.