For loops with split method - returning split words

Hi, could anyone help me understand why my code is returning split words in each line and not the message as a whole - I used split method to run for loop following Mosh’s tutorial and this is how exactly he did. Not sure why mine is showing different result ?

You are printing your output inside the for loop. That means at the end of every loop the output will be printed. All you have to do is take the print statement out of the for loop, like so:

for word in words:
    output += emojis.get(word, word) + ' '

print(output)
1 Like

omg thanks a bunch! I was just itching my head all this time!!!

No problem! Glad I could help. Keep at it!