Merhaba
Uygulamada 3 e basıldığında sözlüğe eklenen elemanın uygulamaya bir sonraki girişte 2 ye basıldığında sözlük elemanları güncellenmediğinden sözlükte karşılığı bulunmuyor. Console uygulamasında bunun bir çözümü olabilir mi. Yada kesin çözüm olarak dosya ya yazdırarak dosya üzerinden nasıl güncelleme yapılır. Yol göstermenizi rica ederim.
print()
print(f"{'English - Turkish Translate and Dictionary Programming':-^100}")
print()
print(f"{'Choose the Process':-^100}")
print(f"{'Press 1 for Sentence Transilation'}\n{'Press 2 for Find Word in Dictionary'}\n"
f"{'Press 3 for Enter New Word to Dictionary'}\n{'Press 4 for English - Turkish Puzzle'}")
print(f"{'End':-^100}")
print()
english_dictionary = {'One': 'Bir', 'Apple': 'Elma', 'Black': 'Siyah', 'See': 'Görmek', 'Year': 'Yıl, Sene'}
while True:
choose_process = input("Enter the number for process you want : ")
print()
if choose_process == "":
break
elif choose_process == "1":
while True:
print()
sentence = input("Enter your sentence : ['Press Enter For Exit'] ")
print()
print(f'{"Gogoşşş Translate System":-^100}')
print()
if sentence == '':
break
for signCharacters in ",./?:-*()[]{}#;":
sentence = sentence.replace(signCharacters, "")
words = set(sentence.lower().split())
words_max_length = 1
for word in words:
if words_max_length < len(word):
words_max_length = len(word)
for word in words:
wordMeaning = english_dictionary.get(word, 'Word Not Found in Dict')
print(f"{word.capitalize():<{words_max_length}} : {wordMeaning.capitalize()}")
print()
print('Exit By User')
print()
elif choose_process == "2":
while True:
word = input("Enter Your Word : ['Press Enter For Exit'] ")
print()
word = word.capitalize()
if word == '':
break
else:
print(f"{word} : {english_dictionary.get(word, 'No Found')}")
padding = max(map(len, english_dictionary.keys()))
english_dictionary = sorted(english_dictionary.items(), reverse=False, key=lambda x: x[0])
total_words = 0
for word in english_dictionary:
total_words += 1
print(word[0].ljust(padding) + " : " + word[1])
print()
print(f"There are {total_words} words in English Dictionary")
print()
print('Exit By User')
elif choose_process == "3":
key = input("Enter Your Key : ")
value = input("Enter Your Value : ")
english_dictionary[key] = value
print(english_dictionary)
print()
elif choose_process == "4":
print('Islem suruyor')
else:
print("Please Enter Number Between 1 - 4")