how to use remove command for deleting list inside list elment
Title
Question
suppose the list example mylist[1,2,3,['a','b','c'],7,8]
how to delete element 'b' from mylist. without using delete command.
i use del mylist[3][1] this command is run but when i use remove. that command is not work.
can you not use the remove command for list in list element deletion?
Python-3.4.3 Getting-started-with-Lists 10-11 min 10-20 sec
Answers:
try this code:
nes_lst = [1, 2, 3, ['a', 'b', 'c'], 7, 8, 'b']
for element in nes_lst:
if isinstance(element, list):
if 'b' in element:
element.remove('b')
else:
if element == 'b':
nes_lst.remove('b')
Login to add comment