Notifications
Clear all

Python program to remove all the occurence of an element from a list

   RSS

0
Topic starter

Output Example:
[10,21,30,31,10,,20,30,10]

enter the element: 10
[21,30,31,20,30]

1 Answer
0
Topic starter

lst=[10,20,30,40,30,50,60,30]

n=int(input('enter the element: '))

i=0

l=len(lst)

while(i<l):

    if(lst[i]==n):

        lst.remove(lst[i])

        l=l-1

    i=i+1

print(lst)

Share: