I got this problem where I’m supposed to write a program that eats a few words (seperated by commas) and spits out a clean list with theese words. I cant get my problem to work. Any ideas?
def wordlist(word):
return word.split(',')
def main ():
sentence = input("write a few words and seperate them with , ")
splitsentence = wordlist(sentence)
for item in splitsentence:
print(item)
main()
You’re printing the list every time instead of the specific item that you’re iterating on:
Instead of
print(splitsetnence), you needprint(item)Also, be conscious of your indentation. The code in the original post does not look correctly indented.