I'm just trying to use some code from books, and there are different exercises, but I wanted to try one with an existing message, I got this far, but I canβt figure out how to complete it. How can i do this?
alphabet = {"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": "--.."}
message = ".-- .... . .-. . / .- .-. . / -.-- --- ..-"
for key,val in alphabet.items():
if message in alphabet:
print(key)
source
share