saving . . . saved how to use remove command for deleting list inside list elment has been deleted. how to use remove command for deleting list inside list elment has been hidden .
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 24-04-20, 12:49 a.m. laxmi_kant1@rediffmail.com

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')
24-04-20, 1:59 p.m. iakashchavan
Thank you sir.
But python is used to reduce the code
26-04-20, 9:29 a.m. laxmi_kant1@rediffmail.com

Login to add comment


Log-in to answer to this question.