Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import sys
  2. import random
  3.  
  4. def keysToValues(dic):
  5. wrong = 0
  6. right = 0
  7. keys = list(dic.keys())
  8. while True:
  9. tmpkey = random.choice(keys)
  10. print("{0}: {1}".format(len(keys), tmpkey))
  11. #print str(len(keys))+":", tmpkey
  12. value = dic[tmpkey]
  13. #answ = raw_input("Translation: ")
  14. if input("Translation: ") in value.split(", "):
  15. print("True. {0}\n".format(value)) #fjf
  16. right += 1
  17. keys.remove(tmpkey)
  18. else:
  19. wrong += 1
  20. print("Wrong! {0}\n".format(value))
  21. if len(keys) < 1:
  22. input("\n\nNothing\nRight - {0}. Wrong - {1}".format(right, wrong))
  23. sys.exit()
  24.  
  25. def main():
  26. try:
  27. wordict = eval(open(sys.argv[1]).read())
  28. except:
  29. print("You have to enter all parameters.\nExample: python wordrepeater.py yourdictionary.json")
  30. input("")
  31. mode = input("Choose mode:\n\t1:Word To Translation;\n\t2:Translation To Word.\n>> ");
  32. if mode == "2": wordict = {wordict[k]:k for k in list(wordict.keys())}
  33. elif mode == "":
  34. print("Exit")
  35. sys.exit()
  36. keysToValues(wordict)
  37.  
  38. if __name__ == "__main__":
  39. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement