0
What's wrong here
message=input(">") words=message.split(' ') emojis={ " :-) " : "☺", " :-[ " : "😔" } output="" for word in words: output+= emojis.get(word,word)+" " print (output) #unable to get emoji as output
5 Respostas
+ 3
You need to add these to the beginning of your program to be able to print unicode symbols in sololearn:
import sys, codecs
sys.stdout = codecs.getwriter('utf-16')(sys.stdout.buffer, 'strict')
Also pay attention that you dont have blank spaces in your dictionary keys, because you already split the input by whitespaces.
Here is a fixed version
https://code.sololearn.com/cOoP1pPXBulf/?ref=app
+ 1
It is specifically for sololearn, because the python environment here does not support unicode by default, only with this little hack.
+ 1
Okay thanks for helping!
0
NUKE you can't directly get the output in an "emoji" format.
You could ask Kuba sikierz... for help, he knows how to do such
0
Tibor Santa I didn't understand why I have to add it. I saw a python tutorial he didn't add it then I have to add it??