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

22nd Jun 2019, 4:03 AM
Ankit Tiwari
Ankit Tiwari - avatar
5 Respuestas
+ 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
22nd Jun 2019, 4:27 AM
Tibor Santa
Tibor Santa - avatar
+ 1
It is specifically for sololearn, because the python environment here does not support unicode by default, only with this little hack.
22nd Jun 2019, 7:31 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Okay thanks for helping!
23rd Jun 2019, 11:38 AM
Ankit Tiwari
Ankit Tiwari - avatar
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
22nd Jun 2019, 4:17 AM
Dlite
Dlite - avatar
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??
22nd Jun 2019, 6:10 AM
Ankit Tiwari
Ankit Tiwari - avatar