def remove_0(l): ''' Remove all instances of 0 from list l.''' while l.count(0) > 0: # Use a method that changes the list, if we want # to affect the list we called the function with. l.remove(0) def main(): nums = [0, 1, 2, 30, 2, 0, 1, 0, 0, 1] print(nums) remove_0(nums) print (nums,"should be",[1, 2, 30, 2, 1, 1] ) nums = [] remove_0(nums) print(nums,"should be the empty list") main()