Google News
logo
Python Program to Access List Items
To access list items in Python, you can use the indexing operator `[]`. The index of the first element in a list is 0, the index of the second element is 1, and so on.

Here's an example program that demonstrates how to access list items in Python :
Program :
# create a list
my_list = ["apple", "banana", "cherry"]

# access the first element
print(my_list[0])

# access the second element
print(my_list[1])

# access the third element
print(my_list[2])
Output :
apple
banana
cherry
In the above example, we create a list called `my_list` that contains three elements. We then access each element using its index with the indexing operator `[]`, and print its value to the console.