Skip to content

Commit 8f77807

Browse files
authored
Update README.md
1 parent 240bf4c commit 8f77807

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

README.md

+32-21
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def get_continue():
5959
if another=='n':
6060
#program ends when user type n
6161
print("Thanks for using the program, goodbye!")
62+
quit() #program ends
6263

6364
# This function is used to encrypt
6465
# English to morse code
@@ -81,30 +82,41 @@ def encode(message):
8182

8283

8384
# This function is used to decrypt
84-
# Morse code to English
85+
# Morse code to Englishdef decrypt(message):
8586
def decode(message):
86-
decipher = ' '
87-
codetext = ''
88-
for code in message:
89-
# checking for space
90-
if (code != ' '):
91-
# to track spaces
92-
a = 0
93-
# for storing morse code of a single character
94-
codetext += code
95-
# for space
87+
message += ' '
88+
decipher = ''
89+
code_text = ''
90+
for letter in message:
91+
92+
# checks for space
93+
if (letter != ' '):
94+
95+
# counter to keep track of space
96+
i = 0
97+
98+
# storing morse code of a single character
99+
code_text += letter
100+
101+
# in case of space
96102
else:
97-
# if a = 1 signifies a new character
98-
a += 1
99-
# if a = 2 signifies a new word
100-
if a == 2:
101-
# adding space to separate words
103+
# if i = 1 that indicates a new character
104+
i += 1
105+
106+
# if i = 2 that indicates a new word
107+
if i == 2 :
108+
109+
# adding space to separate words
102110
decipher += ' '
103111
else:
104-
# to access the keys using value
105-
decipher += list(dictionary.keys())[list(dictionary.values()).index(codetext)]
106-
codetext = ''
112+
113+
# accessing the keys using their values (reverse of encryption)
114+
decipher += list(dictionary.keys())[list(dictionary
115+
.values()).index(code_text)]
116+
code_text = ''
117+
107118
return decipher
119+
108120
#main funtion
109121
def main():
110122
print_intro() #this funtion executes in first
@@ -114,8 +126,7 @@ def main():
114126

115127
#program begins from here
116128
if __name__ == '__main__':
117-
main() #executes main funtion
118-
129+
main() #executes main funtion
119130

120131
```
121132
## Output of the program

0 commit comments

Comments
 (0)