Lesson 24: Morse code

posted May 3, 2018, 8:02 AM by Attila Lengyel   [ updated May 3, 2018, 8:03 AM ]
import morsedict as m

text = input("Give me a text:")

morsecode = ""

for c in text:
  morsecode += m.morsetab[c] + " "
  
print(morsecode)

morsetab2 = {}
for key,val in m.morsetab.items():
  morsetab2[val] = key

morsecode = input("Give me morse:") 
t = ""
for c in morsecode:
  if c == " ":
    print(morsetab2[t])
    t=""
  else:
    t += c
  

Comments