Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import random
- def keysToValues(dic):
- wrong = 0
- right = 0
- keys = list(dic.keys())
- while True:
- tmpkey = random.choice(keys)
- print("{0}: {1}".format(len(keys), tmpkey))
- #print str(len(keys))+":", tmpkey
- value = dic[tmpkey]
- #answ = raw_input("Translation: ")
- if input("Translation: ") in value.split(", "):
- print("True. {0}\n".format(value)) #fjf
- right += 1
- keys.remove(tmpkey)
- else:
- wrong += 1
- print("Wrong! {0}\n".format(value))
- if len(keys) < 1:
- input("\n\nNothing\nRight - {0}. Wrong - {1}".format(right, wrong))
- sys.exit()
- def main():
- try:
- wordict = eval(open(sys.argv[1]).read())
- except:
- print("You have to enter all parameters.\nExample: python wordrepeater.py yourdictionary.json")
- input("")
- mode = input("Choose mode:\n\t1:Word To Translation;\n\t2:Translation To Word.\n>> ");
- if mode == "2": wordict = {wordict[k]:k for k in list(wordict.keys())}
- elif mode == "":
- print("Exit")
- sys.exit()
- keysToValues(wordict)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement