Space issue in Secret Message Challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Space issue in Secret Message Challenge

I have been trying to get this to work for days but can't get this to work with spaces in a sentence. I have tried splitting the input but the join method keeps failing. Any help would be appreciated. import string phrase = str(input()) sentence = string.ascii_lowercase key = dict(zip(sentence,sentence[::-1])) key[" "]=" " print("".join(map(key.get,phrase)))

17th Feb 2020, 1:58 AM
DAYLINER BAND
DAYLINER BAND - avatar
2 Answers
+ 1
Mmm. What about using conditions to determine if the char is a space or not? Btw, try to put the space = space line before the key dict line and give it a try!
17th Feb 2020, 3:43 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
0
Refer this code to get the solution: https://code.sololearn.com/ca17A4a25a0a/#py
11th Jan 2021, 6:18 AM
Venu Gopaal Watada
Venu Gopaal Watada - avatar