translator

posted May 17, 2016, 8:01 AM by Attila Lengyel
dictonary = open("dict.txt", "r")

wordmap = {}
while True:
    line1 = dictonary.readline().rstrip()
    line2 = dictonary.readline().rstrip()
    if line1 =="": break
    print(line1, "in Hungarian is", line2)
    wordmap[line1] = line2
  
while True:
    word1 = input("Give me a word in English:")
    if word1 == "exit": break
    print(word1, "in Hungarian is", wordmap[word1])
    
Comments