Hello. Yesterday I finished chapter 4 of Automate the Boring Stuff with Python (flow control, functions, lists) and I wanted to know how you think my learning is going so far. After finishing each chapter, I usually try to come up with programs to practice what I’ve learned in the topic. I typically do 3-4 projects that come to mind, or I ask ChatGPT to give me an exercise. The first project I’ve done from chapter 4 is a small menu. How do you think my learning is progressing so far? I started learning python 5 days ago and I have some background in math and physics, undergrad.
Here is the code:
menu_options = [ "View profile", "Configure account", "Check notifications", "Log out", "Exit" ] index = 0 while True: print('n=== Main menu ===n') for i, option in enumerate(menu_options): ## Highlight the selected option if i == index: print('>' + option + '<') else: print(option) action = input("nUse the arrows to navigate: 'w' (up), 's' (down), or press enter to select the current option: ").strip().lower() if action == 'w': # Move up index = (index - 1) % len(menu_options) elif action == 's': # Move down index = (index + 1) % len(menu_options) elif action == '': print('You selected the option: ' + menu_options[index]) selection = menu_options[index] options = ['Loading your profile. Please wait... (empty block: this is an example).', 'Loading your account settings. Please wait... (empty block: this is an example)', 'Displaying your notifications (example).', 'You have logged out. See you soon!', 'Exiting the program... See you later!'] if selection in menu_options: position = menu_options.index(selection) print(options[position]) if position == len(menu_options)-1: break else: print("Invalid input. Use 'w', 's', or 'enter'.")
submitted by /u/Pivge
[link] [comments]
r/learnpython Hello. Yesterday I finished chapter 4 of Automate the Boring Stuff with Python (flow control, functions, lists) and I wanted to know how you think my learning is going so far. After finishing each chapter, I usually try to come up with programs to practice what I’ve learned in the topic. I typically do 3-4 projects that come to mind, or I ask ChatGPT to give me an exercise. The first project I’ve done from chapter 4 is a small menu. How do you think my learning is progressing so far? I started learning python 5 days ago and I have some background in math and physics, undergrad. Here is the code: menu_options = [ “View profile”, “Configure account”, “Check notifications”, “Log out”, “Exit” ] index = 0 while True: print(‘n=== Main menu ===n’) for i, option in enumerate(menu_options): ## Highlight the selected option if i == index: print(‘>’ + option + ‘<‘) else: print(option) action = input(“nUse the arrows to navigate: ‘w’ (up), ‘s’ (down), or press enter to select the current option: “).strip().lower() if action == ‘w’: # Move up index = (index – 1) % len(menu_options) elif action == ‘s’: # Move down index = (index + 1) % len(menu_options) elif action == ”: print(‘You selected the option: ‘ + menu_options[index]) selection = menu_options[index] options = [‘Loading your profile. Please wait… (empty block: this is an example).’, ‘Loading your account settings. Please wait… (empty block: this is an example)’, ‘Displaying your notifications (example).’, ‘You have logged out. See you soon!’, ‘Exiting the program… See you later!’] if selection in menu_options: position = menu_options.index(selection) print(options[position]) if position == len(menu_options)-1: break else: print(“Invalid input. Use ‘w’, ‘s’, or ‘enter’.”) submitted by /u/Pivge [link] [comments]
Hello. Yesterday I finished chapter 4 of Automate the Boring Stuff with Python (flow control, functions, lists) and I wanted to know how you think my learning is going so far. After finishing each chapter, I usually try to come up with programs to practice what I’ve learned in the topic. I typically do 3-4 projects that come to mind, or I ask ChatGPT to give me an exercise. The first project I’ve done from chapter 4 is a small menu. How do you think my learning is progressing so far? I started learning python 5 days ago and I have some background in math and physics, undergrad.
Here is the code:
menu_options = [ "View profile", "Configure account", "Check notifications", "Log out", "Exit" ] index = 0 while True: print('n=== Main menu ===n') for i, option in enumerate(menu_options): ## Highlight the selected option if i == index: print('>' + option + '<') else: print(option) action = input("nUse the arrows to navigate: 'w' (up), 's' (down), or press enter to select the current option: ").strip().lower() if action == 'w': # Move up index = (index - 1) % len(menu_options) elif action == 's': # Move down index = (index + 1) % len(menu_options) elif action == '': print('You selected the option: ' + menu_options[index]) selection = menu_options[index] options = ['Loading your profile. Please wait... (empty block: this is an example).', 'Loading your account settings. Please wait... (empty block: this is an example)', 'Displaying your notifications (example).', 'You have logged out. See you soon!', 'Exiting the program... See you later!'] if selection in menu_options: position = menu_options.index(selection) print(options[position]) if position == len(menu_options)-1: break else: print("Invalid input. Use 'w', 's', or 'enter'.")
submitted by /u/Pivge
[link] [comments]