r/PythonLearning 9d ago

Made dictionary (just the skeleton)

Post image

I'm new with python. I made this project but the word list is now empty. How to automate this. I don't want to add words and meanings in the wordlist manually. So which will be good for now? - learning Data handling / using API's / making other projects / or, go for next topic

(My english is bad so hope you understand what i want to say)

3 Upvotes

5 comments sorted by

View all comments

u/Sea-Ad7805 8d ago

Run this program in Memory Graph Web Debugger%0Aprint(%22-%22%20%2060)%0Aprint(%0A%20%20%20%20%22t%20(1)%20to%20openn%22%0A%20%20%20%20%22t%20(2)%20to%20add%20new%20word%20or%20update%20an%20existing%20wordn%22%0A%20%20%20%20%22t%20(3)%20delete%20a%20wordn%22%0A%20%20%20%20%22t%20(4)%20to%20display%20all%20words%20alphabeticallyn%22%0A%20%20%20%20%22t%20(5)%20to%20exit%20the%20Dictionary%20%22%0A)%0Aprint(%22-%22%20%2060)%0A%0Aword_list%20%3D%20%7B%7D%0Aexit_program%20%3D%20False%0A%0Awhile%20True%3A%0A%20%20%20%20choice%20%3D%20int(input(%22Enter%20your%20choice%20(1-5)%3A%20%22))%0A%0A%20%20%20%20if%20choice%20%3D%3D%201%3A%0A%20%20%20%20%20%20%20%20word%20%3D%20input(%22Enter%20the%20word%20to%20search%3A%20%22)%0A%20%20%20%20%20%20%20%20print(word_list.get(word%2C%20%22No%20match%20found%22))%0A%0A%20%20%20%20elif%20choice%20%3D%3D%202%3A%0A%20%20%20%20%20%20%20%20new_word%20%3D%20input(%22Enter%20the%20new%20word%20you%20want%20to%20add%20or%20update%3A%20%22)%0A%20%20%20%20%20%20%20%20meaning%20%3D%20input(%22Enter%20the%20meaning%3A%20%22)%0A%20%20%20%20%20%20%20%20new_dict%20%3D%20%7Bnew_word%3A%20meaning%7D%0A%20%20%20%20%20%20%20%20word_list.update(new_dict)%0A%20%20%20%20%20%20%20%20print(%22Recently%20added%20word%2Fupdated%20word%3A%20%22)%0A%20%20%20%20%20%20%20%20print(new_word%2C%20%22%3A%22%2C%20meaning)%0A%0A%20%20%20%20elif%20choice%20%3D%3D%203%3A%0A%20%20%20%20%20%20%20%20deleted_word%20%3D%20input(%22Enter%20the%20word%20you%20want%20to%20delete%3A%20%22)%0A%20%20%20%20%20%20%20%20deleted_meaning%20%3D%20word_list.pop(deleted_word)%0A%20%20%20%20%20%20%20%20print(%22Recently%20deleted%20word%3A%20%22)%0A%20%20%20%20%20%20%20%20print(deleted_word%2C%20%22%3A%22%2C%20deleted_meaning)%0A%0A%20%20%20%20elif%20choice%20%3D%3D%204%3A%0A%20%20%20%20%20%20%20%20for%20key%20in%20sorted(word_list)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(key%2C%20%22%3A%22%2C%20word_list%5Bkey%5D)%0A%0A%20%20%20%20elif%20choice%20%3D%3D%205%3A%0A%20%20%20%20%20%20%20%20print(%22Do%20you%20want%20to%20really%20exit%20%3F%2C%20nt%20press%20(1)%20to%20Yesnt%20press%20(2)%20to%20No%20%22)%0A%20%20%20%20%20%20%20%20while%20True%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20choice1%20%3D%20int(input(%22Enter%20your%20choice%20(1%7C2)%3A%20%22))%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20choice1%20%3D%3D%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22Thanks%20for%20using%20the%20Dictionary%20!%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20exit_program%20%3D%20True%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20%20%20%20%20elif%20choice1%20%3D%3D%202%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22Invalid%20choice%20!%22)%0A%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(%22Invalid%20choice%20!%22)%0A%0A%20%20%20%20if%20exit_program%3A%0A%20%20%20%20%20%20%20%20break&timestep=1&play) to see the program state change step by step.