MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / decrypt

Function decrypt

projects/MorseCode Translator/main.py:70–102  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

68# Function to decrypt the string
69# from morse to english
70def decrypt(message):
71 # extra space added at the end to access the
72 # last morse code
73 message += " "
74
75 decipher = ""
76 citext = ""
77 for letter in message:
78 # checks for space
79 if letter != " ":
80 # counter to keep track of space
81 i = 0
82
83 # storing morse code of a single character
84 citext += letter
85
86 # in case of space
87 else:
88 # if i = 1 that indicates a new character
89 i += 1
90
91 # if i = 2 that indicates a new word
92 if i == 2:
93 # adding space to separate words
94 decipher += " "
95 else:
96 # accessing the keys using their values (reverse of encryption)
97 decipher += list(MORSE_CODE_DICT.keys())[
98 list(MORSE_CODE_DICT.values()).index(citext)
99 ]
100 citext = ""
101
102 return decipher
103
104
105# Hard-coded driver function to run the program

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected