PDA

View Full Version : Looping through and removing parts of a list


Python
07-16-2009, 07:42 PM
>>> mylist = ['bunnies', 'apples', 'animals', 'fruit', 'amsterdam'] >>> for x in mylist: print '--------------' print x if x[0] == 'a': print "Removing ",x mylist.remove(x) --------------