+ 4
How can I set this code so that don't go next line
morce_code = { "a" : ".-","b" : "-...","c" : "-.-.","d" : "-..","e" : ".","f" : "..-.","g" : "--.","h" : "....","i" : "..","j" : ".---","k" : "-.-", "l" : ".-..","m" : "--", "n" : "-.", "o" : ".--.", "p" : ".--.", "q" : "--.-", "r" : ".-.", "s" : "...", "t" : "-", "u" : "..-", "v" : "...-", "w" : ".--", "x" : "-..-", "y" : "-.--", "z" : "--..", " " : " " } text = input(" ") for char in text: morce = "" morce += morce_code[char] print(morce)
12 Respostas
+ 10
morce_code = {
"a" : ".-","b" : "-...","c" : "-.-.","d" : "-..","e" : ".","f" : "..-.","g" : "--.","h" : "....","i" : "..","j" : ".---","k" : "-.-", "l" : ".-..","m" : "--", "n" : "-.", "o" : ".--.", "p" : ".--.", "q" : "--.-", "r" : ".-.", "s" : "...", "t" : "-", "u" : "..-", "v" : "...-", "w" : ".--", "x" : "-..-", "y" : "-.--", "z" : "--..", " " : " "
}
text = input()
morce = ""
for char in text:
#morce = "" here this reset in iterations.
morce += morce_code[char]
print(morce) # after and outside loop.
# is this way you are trying?
+ 3
Jayakrishna 🇮🇳
O yes
It works
Thank you so much again 💓
+ 2
Code i posted printing in one line only.
which code you are trying?
What is your sample input and expected output....
+ 2
AmIraN gh Yes. Test the code which i posted above. It give you that expected output only..
The print( morce) i added after loop. Not inside. And morce declared before loop. Not inside loop.. Which code you are using ?
+ 1
Yap
+ 1
Jayakrishna 🇮🇳 it goes next line again
+ 1
I want print all morce code in one line
+ 1
Jayakrishna 🇮🇳
My input is amir
But it prints
.-
--
..
.-.
I want it to print
.- -- .. .-.
0
How can
0
Sudeys abdu look at the best answer
from Jayakrishna 🇮🇳
0
Sudeys abdu https://code.sololearn.com/cw52tWH2fWH0/?ref=app