td> Output: Traceback (last call was last): File 8a33ebbf716678c881331d75e0b85fe6.py, line 15, in & lt; module & gt; print x  IndexError: string index out of range
# Python program to illustrate slicing in lines
"Geeks at work"
# Prints the third character, starting with 0
# Prints the 7th character
# Prints the third character from the back, starting at -1
# Line length is 10, so it is out of bounds
Traceback (last call was last): File 8a33ebbf716678c881331d75e0b85fe6.py, line 15, in & lt; module & gt; print x  IndexError: string index out of range
To extract a substring from an entire string, we use the following syntax
string_name [start: end: step] pre>
Note: we can also slice a line using the beginning and only , and steps are optional.
LCO TON Ge
This article courtesy of Arpit Agarwal. If you like Python.Engineering and you want to contribute, you can also write an article and mail it to [email protected] See your article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you`d like to share more information on the topic under discussion