Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python remove list from nested list

# If you know the index of the item you want, you can use the pop() method. It modifies the list and returns the removed item.
L = ['a', ['bb', 'cc', 'dd'], 'e']
x = L[1].pop(1)
print(L)
# Prints ['a', ['bb', 'dd'], 'e']

# removed item
print(x)
# Prints cc
Source by www.learnbyexample.org #
 
PREVIOUS NEXT
Tagged: #python #remove #list #nested #list
ADD COMMENT
Topic
Name
1+4 =