I'm making a program that takes input and coverts it to morse code in the form of computer beeps but I can't figure out how to make it so I can put more than one letter in the input without getting an error.
Here is my code:
import winsound
import time
morseDict = {
'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': '--..'
}
while True:
inp = raw_input("Message: ")
a = morseDict[inp]
morseStr = a
for c in morseStr:
print c
if c == '-':
winsound.Beep(800, 500)
elif c == '.':
winsound.Beep(800, 100)
else:
time.sleep(0.4)
time.sleep(0.2)
Right now it takes one letter at a time but I want it to take phrases.