Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import random as rnd
- import pickle
- Dictionary = {}
- if not os.path.exists('gg.pickle'):
- c = 'y'
- while c == 'y':
- eng = input('Enter English word: ')
- rus = input('Enter Russian word: ')
- Dictionary[rus] = eng
- c = input('One more (y or n): ')
- with open('gg.pickle', 'wb') as f:
- pickle.dump(Dictionary, f)
- with open('gg.pickle', 'rb') as f:
- Dictionary = pickle.load(f)
- try:
- while bool(Dictionary):
- ru_word = rnd.choice(list(Dictionary.keys()))
- inp = input('Translate this: ' + ru_word+'\n')
- if inp =='/q':
- raise KeyboardInterrupt
- if inp == Dictionary[ru_word]:
- del Dictionary[ru_word]
- print('Succesful')
- print('Your English is very Well!\n')
- except KeyboardInterrupt:
- print('Okey :(')
- with open('gg.pickle', 'rb') as f:
- Dictionary = pickle.load(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement