+ 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))

22nd Jun 2019, 4:58 AM
Ankit Tiwari
Ankit Tiwari - avatar
2 ответов
+ 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"
22nd Jun 2019, 5:02 AM
Anna
Anna - avatar
+ 1
Okay thanks Anna
22nd Jun 2019, 6:01 AM
Ankit Tiwari
Ankit Tiwari - avatar