Introduction Variables Data Types Numbers Casting Strings Boolean Operators Lists Tuples Dictionaries If-Else While Loops For Loops Functions Arrays Scope Modules User Input File Handling Python Maths

Welcome to the lesson on Python Strings - Slicing

You can return a range of characters by using the slice syntax.

Specify the start index and the end index, separated by a colon, to return a part of the string.

Some Examples: Get the characters from position 3 to position 7 (not included):

syntax

Note: The first character has index 0.

Try it out yourself

Slice From the Start

By leaving out the start index, the range will start at the first character:

Some Examples: Get the characters from the start to position 5 (not included):

syntax
Try it out yourself

Slice To the End

By leaving out the end index, the range will go to the end:

Some Examples: Get the characters from position 2, and all the way to the end:

syntax
Try it out yourself

End of Python Strings - Slicings

You have learned String Slicing in simple terms. Let's proceed on to Modify Strings.

Next
Back To Top