chat1
import enum
def get_user_choices():
input_str = input("\nEnter your choices by number (e.g., 1,2): ")
choice_numbers = input_str.split(',')
choices = []
try:
for number in choice_numbers:
number = int(number.strip())
if number < 1 or number > len(MenuOptions):
print(f"Number out of range. Please enter a number between 1 and {len(MenuOptions)}.")
else:
choices.append(MenuOptions(number))
except ValueError:
print("Invalid input. Please enter valid numbers.")
except IndexError:
print("Invalid choice number.")
return choices
def process_choices(choices):
for choice in choices:
if choice is MenuOptions.EXIT:
print("Exiting...")
return False
else:
print(f"You selected: {choice.value}")
return True
def main():
while True:
display_menu()
choices = get_user_choices()
if not process_choices(choices):
break
if __name__ == "__main__":
main()