Created
April 7, 2016 12:26
-
-
Save Xotabu4/ab8de8076b0dcf6cd71e10a2f569c4ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding=utf-8 | |
| ALPHABET = u'абвгдеёжзийклмнопрстуфхцчшщъыьэюя' | |
| with open('text.txt') as f: | |
| lines = f.readlines() | |
| lines = [line.decode("utf-8") for line in lines] | |
| print '###TASK 1:' | |
| for line in lines: | |
| if len(line) > 20: | |
| print line | |
| print '###TASK 2' | |
| text_no_lines = ''.join(lines) | |
| CODES = [] | |
| for letter in ALPHABET: | |
| CODES.append(text_no_lines.rfind(letter)) | |
| for code, letter in zip(CODES, ALPHABET): | |
| print code, letter | |
| print '###TASK 3' | |
| words = [] | |
| strr = raw_input('Enter word to encrypt: ').decode("utf-8") | |
| while strr: | |
| words.append(strr) | |
| strr = raw_input('Enter word to encrypt: ').decode("utf-8") | |
| e_words = [] | |
| for word in words: | |
| e_word = '' | |
| for letter in word: | |
| index = ALPHABET.find(letter) | |
| c = CODES[index] | |
| e_word += str(c) | |
| e_words.append(e_word) | |
| print ' '.join(e_words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment