ans = input("Enter a sentence: ")
count = ans.count(" ") + 1
final = ""
for i in range(count):
space = ans.find(" ")
word = ans[0:space]
final += word + ","
ans = ans.replace(word,"")
print(final)
The code above shows my attempt to separate words in a sentence with a ",". After the first loop the variable "word" is empty and does not take on the next part of the sentence. Please help