0

So i made a code that converts English to morse but each word appears in next line like

If i type hello the answer would be(in morse tho) H E L L O https://code.sololearn.com/cyb9mKc42s7I/?ref=app

1st Jan 2022, 3:22 PM
The_badbatplayz
The_badbatplayz - avatar
4 Antworten
+ 2
You should use dictionary that would be much better but nevermind I know there must be better Solutions but I can't think anything better https://code.sololearn.com/cP5842TpHpPA/?ref=app
1st Jan 2022, 3:35 PM
Atul
Atul - avatar
+ 4
You should write your code like this for c in ime: c=c.upper() if (c =="A"): print (".-",end="") elif (c=="B"): print("-...",end="") elif (c=="C"): print("-.-.",end="") elif (c=="D"): print("-..",end="") elif (c=="E"): print(".",end="") elif (c=="F"): print("..-.",end="") elif (c=="G"): print("--.",end="") elif (c=="H"): print("....",end="") elif (c=="I"): print("..",end="") elif (c=="J"): print(".---",end="") elif (c=="K"): print("-.-",end="") elif (c=="L"): print(".-..",end="") and so on until the last of if condition
1st Jan 2022, 3:55 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 4
I write a code like yours https://code.sololearn.com/cr9z68AZhe6z
1st Jan 2022, 5:20 PM
FanYu
FanYu - avatar
+ 3
print function by default make new line after printing any thing inside it So if you want to change the separator u should put "," comaa then end="" Like this print ("Hello") print ("world!") Output will be Hello World But if u write print ("Hello",end="") print("world!) Output Helloworld! Without any space between the two words but if u want to make space U should put one space between the double qoutes of end keyword So the code should be print ("Hello",end=" ") print("world!) Output Helloworld!
1st Jan 2022, 3:50 PM
Muhammad Galhoum
Muhammad Galhoum - avatar