Contact: aviboots(AT)netvision.net.il
40,836 questions
53,240 answers
573 users
lst = [4, 3, 6, 8, 1, 2, 7, 9, 5] to_remove = 8 if to_remove in lst: lst.remove(to_remove) print(lst) ''' run: [4, 3, 6, 1, 2, 7, 9, 5] '''
lst = [4, 3, 6, 8, 1, 2, 7, 9, 5] to_remove = 2 if to_remove in lst: lst.pop(lst.index(to_remove)) print(lst) ''' run: [4, 3, 6, 8, 1, 7, 9, 5] '''