Write a program which will achieve given a Python list, remove all occurrence of an input from the list


Topic: Write a program which will achieve given a Python list, remove all occurrence of an input from the list

Solution

list1 = [5, 20, 15, 20, 25, 50, 20]
def removeValue(sampleList, val):
   return [value for value in sampleList if value != val]
   
resList = removeValue(list1, 20)
print(resList)



List all Python Programs