I'm working on a beginner project to detect anagrams. Part of it is removing all the spaces from each word. To do this, I'm using
for i in list1:
if(i == " "):
list1.remove(i)
for i in list2:
if(i == " "):
list2.remove(i)
It removes every space, except when two or more spaces are adjacent, and then it always leaves one space