initial commit
This commit is contained in:
commit
39f56a3b10
83 files changed
+3583
No files matched your search
@@ -0,0 +1,41 @@
|
||||
|
||||
word = {}
|
||||
|
||||
def train():
|
||||
with (open("vocab.txt", "r+")) as vocab:
|
||||
for line in vocab:
|
||||
word[line] = vocab.readline()
|
||||
|
||||
try:
|
||||
while True:
|
||||
if input(f"what is the translation of '{word[0]}'? ") in word[1]:
|
||||
print("correct!")
|
||||
break
|
||||
else:
|
||||
print("incorrect, try again")
|
||||
|
||||
except KeyError:
|
||||
print("no such word in the library!")
|
||||
print()
|
||||
|
||||
def save_vocab():
|
||||
ger = input("enter a german word: ")
|
||||
en = input("enter an english translation: ")
|
||||
|
||||
with (open("vocab.txt", "w")) as vocab:
|
||||
vocab.write(f"{ger}, {en}")
|
||||
|
||||
|
||||
|
||||
while True:
|
||||
print("1. Add a new word")
|
||||
print("2. Train")
|
||||
print("3. Quit")
|
||||
|
||||
user_inp = input()
|
||||
if user_inp == "1":
|
||||
save_vocab()
|
||||
if user_inp == "2":
|
||||
train()
|
||||
if user_inp == "3":
|
||||
break
|
||||
Reference in new issue
Block a user