Or maybe that’s not the proper way to approach this issue…
def main():
active = True
while(active):
global thread_viewed
thread_viewed = False
[print("Welcome to the (name) Forum!\n" +
"To make a post, type '/post'.\n" +
"To quit, type '/quit'.\n" +
"To view a post, type '/view post_number'.\n" +
"Otherwise, press any other key.\n")
display_posts()]
command = input()
if command == "/quit":
active = False
elif command == "/post":
post()
elif command.startswith("/view"):
view(command)
else:
pass
For this section of code, I have a couple functions that run (e.g view and post). When these functions finish running, the loop starts from the beginning and the menu is displayed again. This is good.
The issue is with my else statement. While this behaviour is okay for the functions, it creates an issue where if the user types any other key, the menu prints again even if they don’t need to see it again. I’d like to know if there’s a way to skip the bits between the square brackets for the else clause, or if there’s any other way to skip the menu for displaying again if a user does not type “/quit”, “/post”, or “/view”.
Thanks