0

How to print on the same line?

input: hello world Sample output: svool dliow https://code.sololearn.com/cMptCB5UTSpH/?ref=app

12th Jul 2020, 2:21 PM
Hello World
Hello World - avatar
6 Answers
+ 4
Your albhabet don't have space, so will be ignored so add else part to print as it is. Next is your logic correct? Do you need to print reverse? No I think, A logic: If z to print in place of a, then alphabet['z' - ch] will give you 'a'... In python, I think it need some syntax changes, not exact one...
12th Jul 2020, 2:38 PM
Jayakrishna 🇼🇳
+ 5
To keep spaces as they are entered during input, you can split() your input to a list. For split() use a space as separator. Then you can iterate through your list of words and encode them. If this is done, you can join() the elements of the list to a string, that can be printed without any trouble.
12th Jul 2020, 3:32 PM
Lothar
Lothar - avatar
+ 3
print(new_word, end= "") Default end = "\n" so overwrite it like end = "" ie none
12th Jul 2020, 2:23 PM
Jayakrishna 🇼🇳
+ 1
Thank you Lothar for helping me
12th Jul 2020, 3:49 PM
Hello World
Hello World - avatar
0
Jayakrishna🇼🇳 thank you this is nice but there is no spase between them like(svool dliow)
12th Jul 2020, 2:28 PM
Hello World
Hello World - avatar
0
Thank you again this was helpful
12th Jul 2020, 2:47 PM
Hello World
Hello World - avatar