Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
from pathlib import Path
import os
cipher = {
'a':'v',
'b':'h',
'c':'r',
'd':'j',
'e':'t',
'f':'x',
'g':'s',
'h':'a',
'i':'e',
'j':'f',
'k':'b',
'l':'n',
'm':'o',
'n':'i',
'o':'g',
'p':'l',
'q':'m',
'r':'z',
's':'q',
't':'u',
'u':'c',
'v':'k',
'w':'d',
'x':'p',
'y':'y',
'z':'w',
' ': '}',
'\n': '^',
',': '5',
'!': '[',
':':'-',
')':'*',
'.': '%'
}
encrypted_message = Path("C:\Users\sriha\Stat4188\HW1\encrypted_message_one.txt")
with open(encrypted_message, "r") as f:
encrypted_message = f.readline()
# encrypted_file = open("encrypted_message_one.txt", "r")
# encrypted_message = encrypted_file.readline()
print(encrypted_message)
# Write code below
#print('Hello World')
#print(type(cipher))
#decipher = cipher[')']
#print(decipher)
#print("HELLO")
decrypted_message = ''
reversed_cipher = {}
for key, value in cipher.items():
reversed_cipher[value] = key
for char in encrypted_message:
#if char == 's':
#print("Yes it's printing the first char")
new_char = reversed_cipher.get(char, '')
decrypted_message = decrypted_message + new_char
print(decrypted_message)