January 2019
Beginner
318 pages
8h 23m
English
We can access the values from a list by using index values. We will specify the index number in [ and ]. Index starts from 0. Refer to the given example:
#!/usr/bin/python3cities = ['Mumbai', 'Bangalore', 'Chennai', 'Pune']numbers = [1, 2, 3, 4, 5, 6, 7 ]print (cities[0])print (numbers[1:5])Output:Mumbai[2, 3, 4, 5]
Read now
Unlock full access