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
For courses in business intelligence or decision support systems. A managerial approach to understanding business intelligence systems. To help future managers use and understand analytics, Business...
As the title promises, this book will introduce you to one of the world’s most popular programming languages: Python. It’s aimed at beginning programmers as well as more experienced programmers wh...
A Gentle Introduction to Numerical Simulations with Python 3.6. Computing, in the sense of doing mathematical calculations, is a skill that mankind has developed over thousands of years. Programmin...
Pandas for Everyone: Python Data Analysis (Addison-Wesley Data & Analytics Series), 1st Edition. Pandas for Everyone brings together the practical knowledge and insights you need to solve real-worl...