the following code is me that wrote it to remove all the val numbers in the list nums. But for some reason I only managed to remove all of them except for the last one. Does anyone know how to remove all of the val numbers inside the list nums
def removeElement(nums,val):
for i in nums:
if i == val:
nums.remove(nums[nums.index(i)])
return nums
removeElement([3,5,2,637,2,2,73,73,2,5,26,2,62,26,2],2)