DEV Community

Tommi k Vincent
Tommi k Vincent

Posted on

Accessing Values in Python-Tuples .

To access values in a tuple , we use square brackets for slicing along with the index or indices to obtain value available at that index.
Try below code.

destination = ["kenya",'Las-Vegas','Colombia','London','Moscow','Paris']

ranks  = (1,2,3,4,5,6,7,8,9,10)

print('destination[1]:',destination[1])

print('ranks[5]:',ranks[5])


apps = ['tiktok','instragram','x','whatsapp','linkedin']

print('apps located at [2]',apps[2])
Enter fullscreen mode Exit fullscreen mode

*output *
When the above code is executed, it produces the following result.

destination[1]: Las-Vegas
ranks[5]: 6
apps located at [2] x 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)