Quantcast
Viewing all articles
Browse latest Browse all 14069

Why does the script menu function repeat after selection

async def main_menu():    menu_active = True  # Variable to control the display of the menu    while menu_active:        print("\nMain Menu:")        print("1. Activate script")        print("2. Account authorization")        print("3. Exit")        choice = input("Enter the option number: ")        os.system('cls')        if choice == '1':            headless_choice = input("Do you want to use headless mode? (yes/no): ").lower() == 'yes'            driver = initialize_browser(headless=headless_choice)            driver.get("https://my.site")            os.system('cls')        elif choice == '2':            authorize_system()        elif choice == '3':            print("Exiting the program...")            break        else:            print("Invalid choice. Please try again.")if __name__ == "__main__":    asyncio.run(main_menu())

By logic, after I select function 1, the script launches the browser and should perform its actions, and the menu should not appear again because I have already chosen to execute the function. How do I make it so that after I choose function 1, the menu does not appear again?

break , while flags,


Viewing all articles
Browse latest Browse all 14069

Trending Articles