20 August 2020
Code
Note: .pop() removes an item from a list at a given index and also returns it.
# Create a list
x = [11,12,13]
# Remove
y = x.pop(1) # (index)
# Output
print('List after .pop():', x)
print(type(x), '\n')
print('Return by .pop():',y)
print(type(y))
List after .pop(): [11, 13]
<class 'list'>
Return by .pop(): 12
<class 'int'>
Any errors in code above?
Please send a message.