1
0

Added user input, and checking if word is present in the dict to show a translation

This commit is contained in:
2022-11-04 20:41:28 +01:00
parent 98d707d458
commit 4aa091a3d0
+18 -1
View File
@@ -14,4 +14,21 @@ for line in fobj:
woerter[zuordnung[0]] = zuordnung[1]
#sobald alle werte im Dictionary woerter abgelegt sind, Datei schließen
fobj.close()
fobj.close()
# unendliche Schleife zur Abfrage der Übersetzung
while True:
# Abfragen des Wortes zum Übersetzen
wort = input("Geben Sie ein Wort ein: ")
# prüfen ob das Wort im Dictionary vorkommt
if wort in woerter:
#Ausgabe der Übersetzung, Wort vorhanden
print("Das deutsche Wort lautet:", woerter[wort])
# Wort nicht im Dictionary
else:
#Ausgabe Fehlermeldung, Wort nicht vorhanden
print("Das Wort ist unbekannt")