ERROR IN PYTHON CODE. SCREEN SHOT ATTACHED   def morse_code(text):  tranlation_dic = {   "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": "--..",   ".-": "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"  }   menu = """ Morse Code Translator 0: Exit 1: Translate a word into Morse Code 2: Translate Morse Code to text. """ done = False while not done:  print(menu)  selection = input('Please make a selection: ')  if selection == "0":   done = True  elif selection == "1":   morseCode = input('Please enter a word to be translated to Morse Code: ')   morseCode = morseCode.upper()   print('Morse Code for the provided letter is: ', morse_code(morseCode))  elif selection == "2":   morseCode = input('Please enter a word from the Morse Code Tranlator menu: ')   print('Text for the provided Morse Code is: ', morse_code(morseCode))  else:   print('Selection is invalid. Only 0, 1, and 2 are the acceptable inputs.')    print('Done!')

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

ERROR IN PYTHON CODE. SCREEN SHOT ATTACHED

 

def morse_code(text):
 tranlation_dic = {
  "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": "--..",
  ".-": "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"
 }
 

menu = """
Morse Code Translator

0: Exit
1: Translate a word into Morse Code
2: Translate Morse Code to text.

"""

done = False

while not done:

 print(menu)

 selection = input('Please make a selection: ')

 if selection == "0":
  done = True

 elif selection == "1":

  morseCode = input('Please enter a word to be translated to Morse Code: ')
  morseCode = morseCode.upper()
  print('Morse Code for the provided letter is: ', morse_code(morseCode))

 elif selection == "2":

  morseCode = input('Please enter a word from the Morse Code Tranlator menu: ')
  print('Text for the provided Morse Code is: ', morse_code(morseCode))

 else:
  print('Selection is invalid. Only 0, 1, and 2 are the acceptable inputs.')
  
print('Done!')

64
65
66
67
68
69 while not done:
70
71
72
73 selection=input('Please make a selection: ')
74
75 ▾ if selection == "0":
76
done = True
77
78 -
79
80 morseCode=input('Please enter a word to be translated to Morse Code: ')
morseCode = morseCode.upper()
81
82
print("Morse Code for the provided letter is: ", morse_code(morseCode))
83
84 ▾ elif selection == "2":
85
86
*
done False
▶ Run
>_
morseCode=input('Please enter a word from the Morse Code Tranlator menu: ')
Ln: 92, Col: 15 (1636 selected)
hi
print (menu)
elif selection == "1":
Share Command Line Arguments
Traceback (most recent call last):
File "Untitled8.py", line 82, in <module>
print("Morse Code for the provided letter is: ", morse_code(morseCode))
File "Untitled8.py", line 56, in morse_code
return tranlation_dic[text]
KeyError: 'HI'
** Process exited - Return Code: 1 **
Press Enter to exit terminal
Transcribed Image Text:64 65 66 67 68 69 while not done: 70 71 72 73 selection=input('Please make a selection: ') 74 75 ▾ if selection == "0": 76 done = True 77 78 - 79 80 morseCode=input('Please enter a word to be translated to Morse Code: ') morseCode = morseCode.upper() 81 82 print("Morse Code for the provided letter is: ", morse_code(morseCode)) 83 84 ▾ elif selection == "2": 85 86 * done False ▶ Run >_ morseCode=input('Please enter a word from the Morse Code Tranlator menu: ') Ln: 92, Col: 15 (1636 selected) hi print (menu) elif selection == "1": Share Command Line Arguments Traceback (most recent call last): File "Untitled8.py", line 82, in <module> print("Morse Code for the provided letter is: ", morse_code(morseCode)) File "Untitled8.py", line 56, in morse_code return tranlation_dic[text] KeyError: 'HI' ** Process exited - Return Code: 1 ** Press Enter to exit terminal
Expert Solution
Step 1

Required language is Python: 

Code is working well, please try again. Error is resolved.

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education