+ 1
Why it always showing unexpected indent or return out of function?SMH!! please help
def emoji_convertor(message): words=message.split(' ') emojis={ " :-) " : "☺", " :-[ " : "😔" } output="" for word in words: output+= emojis.get(word,word)+" " return output message=input(">") print (emoji_convertor(message))
2 Respostas
+ 5
The lines "emojis" and "output" and your for loop are not indented, so they're not part of the function definition. Which leads to the problem that you're using the return keyword outside of a function
/Looking at your other questions, you're basically asking the same question again and again. You need to understand how indentation works in Python. Please refer to the link I posted in your other thread, or google "indentation in python"
+ 1
Okay thanks Anna