The first element of a list can be accessed using index 0 or by using the pop()
method with an argument of 0 to remove and return the first element. Here are two examples:
Example 1:
fruits = ['apple', 'banana', 'orange', 'kiwi'] first_fruit = fruits[0] print(first_fruit)
Output:
‘apple’
Example 2:
fruits = ['apple', 'banana', 'orange', 'kiwi'] first_fruit = fruits.pop(0) print(first_fruit)
Output:
‘apple’