I have my simple method which I have used in college.
line = "I have a nice day."
end = 1000
while end != 0:
line.replace(" ", " ")
end -= 1
This will replace every double space with a single space and will do it 1000 times. It means you can have 2000 extra spaces and will still work. :)