January 2019
Beginner
318 pages
8h 23m
English
To access values in a tuple, use the square brackets for slicing along with the index or indices to obtain the value available at that index or indices, as shown in the following example:
#!/usr/bin/python3cities = ('Mumbai', 'Bangalore', 'Chennai', 'Pune')numbers = (1, 2, 3, 4, 5, 6, 7)print (cities[3])print (numbers[1:6])Output:Pune(2, 3, 4, 5)
Read now
Unlock full access