Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- from collections import Counter
- try:
- with open('cipher.txt') as file:
- data = file.read()
- alphabet = set(string.ascii_uppercase)
- except FileNotFoundError:
- print('Error')
- counts = Counter(data)
- dictionary = {}
- keys = data[0:26]
- counter = 0
- itera=iter(dictionary)
- for key, count in counts.most_common():
- if key in alphabet:
- dictionary[key] = keys[counter]
- counter += 1
- message = ""
- for letters in data:
- try:
- message += dictionary[letters]
- except KeyError:
- message += letters
- continue
- print(message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement