10 lines
347 B
Python
10 lines
347 B
Python
# Retrieve an element directly from the array.
|
|
item = array[index]
|
|
|
|
# Use the array like a stack. Note that using the pop() method removes the element.
|
|
array.pop() # Pop last item in a list
|
|
array.pop(0) # Pop first item in a list
|
|
|
|
# Using a negative element counts from the end of the list.
|
|
item = array[-1] # Retrieve last element in a list.
|