Python Array – pop the first element of the array

pop method – list.pop()

Here is an example for you

# Python code to understand how to pop the first element of the array
# www.codewindow.in

a = [10, 11, 12, 13, 14]

#using pop method
x = a.pop(0)
print(a)
print("The popped element: ",x)

Output:

[11, 12, 13, 14]
The popped element: 10

Explanation:
Here, pop(0) pops the first element from the list and returns it to x (variable).


You Missed

Also Checkout