From 1dc810d52d13f16935081f488d25faa3cb61b533 Mon Sep 17 00:00:00 2001 From: Back-end and front-end developer <71826040+RgTheGreat@users.noreply.github.com> Date: Mon, 25 Oct 2021 12:07:14 +0530 Subject: [PATCH] Create text_to_morse_code.py --- .../text_to_morse_code/text_to_morse_code.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 projects/text_to_morse_code/text_to_morse_code.py diff --git a/projects/text_to_morse_code/text_to_morse_code.py b/projects/text_to_morse_code/text_to_morse_code.py new file mode 100644 index 00000000..461c8f56 --- /dev/null +++ b/projects/text_to_morse_code/text_to_morse_code.py @@ -0,0 +1,42 @@ +#all_the symbols +symbols = { + "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": "--..", +} + +#the user has to tyoe a word +ask = input("type: ") + + +length = len(ask) +output = "" + +for i in range(length): + if ask[i] in symbols.keys(): + output = output + " " + symbols.get(ask[i]) + +print(output)