March 2020
Beginner to intermediate
352 pages
8h 40m
English
Python provides an indexing mechanism to access any character from any string. The index of any string starts with 0. We can also access any character from the back of any string, using a negative index value. For example, -1 indicates the last character of the string, -2 refers to the second-to-last character, and so on. Note that if we try accessing any index that is not within the limit of the string, Python alerts us with a TypeError.
Here's the Python code used to access the characters of a string:
# characters of String String = "Exploratory Data Analysis"# Printing First character print("\nFirst character of String is: ") print(String[0]) # Printing Last character print("\nLast character of String is: ...Read now
Unlock full access