What does [2:] syntax do on str in Python?

Experience Level: Junior
Tags: Python

Answer

This returns all the items from the position with index two or higher.

In case of string, if the string has value "Hello", the returned value will be "llo".

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself