Skip to content

Commit 0af4ad6

Browse files
authored
Update Code_Alpha.py
Symbol coding/decoding enabled
1 parent cebd305 commit 0af4ad6

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Code_Alpha.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
alphabets = ['A','B','C','D','E','F','G','H',
22
'I','J','K','L','M','N','O','P',
3-
'Q','R','S','T','U','V','W','X','Y','Z'] # series of alphabets in order
3+
'Q','R','S','T','U','V','W','X','Y','Z','.','#','%','!','?','/',','] # series of alphabets in order (plus some symbols)
44

55
def find_index(letter):
66
'''Returns the index of the alphabet in the series of alphabet'''
@@ -19,7 +19,7 @@ def code_cyclic(index, letter):
1919
# I had to use a separate variable 'index' to avoid the confusion the program gets when
2020
# choosing the index of the letter (eg, in the case of "HELLO", there are 2 'l' 's and this will cause confusion
2121
# This problem has been solved in the upcoming function.
22-
return 26 * index + (find_index(letter) + 1)
22+
return 33 * index + (find_index(letter) + 1)
2323

2424
def code_word(word):
2525
'''codes each word with an array of numbers'''
@@ -75,7 +75,7 @@ def decode(nstring):
7575
if i != '-':
7676
num += i
7777
else:
78-
word_str += alphabets[(int(num) % 26) - 1]
78+
word_str += alphabets[(int(num) % 33) - 1]
7979
num = ""
8080
print(word_str)
8181

0 commit comments

Comments
 (0)