Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import os
  2. import random as rnd
  3. import pickle
  4.  
  5. Dictionary = {}
  6. if not os.path.exists('gg.pickle'):
  7. c = 'y'
  8. while c == 'y':
  9. eng = input('Enter English word: ')
  10. rus = input('Enter Russian word: ')
  11. Dictionary[rus] = eng
  12. c = input('One more (y or n): ')
  13. with open('gg.pickle', 'wb') as f:
  14. pickle.dump(Dictionary, f)
  15. with open('gg.pickle', 'rb') as f:
  16. Dictionary = pickle.load(f)
  17. try:
  18. while bool(Dictionary):
  19. ru_word = rnd.choice(list(Dictionary.keys()))
  20. inp = input('Translate this: ' + ru_word+'\n')
  21. if inp =='/q':
  22. raise KeyboardInterrupt
  23. if inp == Dictionary[ru_word]:
  24. del Dictionary[ru_word]
  25. print('Succesful')
  26. print('Your English is very Well!\n')
  27. except KeyboardInterrupt:
  28. print('Okey :(')
  29. with open('gg.pickle', 'rb') as f:
  30. Dictionary = pickle.load(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement