[Solved] Using a loop to continue or break the program if condition is met


Sorry I read it several times, but I still don’t quite understand what you mean.

Do you want users to enter the name repeatedly until the name is in the list? Once the name is in the list is allowed to proceed to the next stage?

lucky_numbers = [4, 8, 15, 17, 23, 42]
players = ["Kevin", "Stacey", "Jim", "Monica", "Donnie"]

is_login_success = False

while True:
    name = input("Please enter your name or enter `Exit` to exit game\n> ").capitalize().strip() 

    if name == "Exit":
        is_login_success = False
        print("Bye bye! Hope see you soon.")
        break
    elif name in players:
        is_login_success = True
        print(f"Ok {name}, move on..")
        break
    else:
        print("Uh oh, you are not on the players list!")
    
    print()


if is_login_success:
    # play game

In addition, make some suggestions about the game:

  1. Prompt user for number range of lottery and check input
  2. Is your winning condition to enter the same number in the same order? If only the same number is required, there is something wrong with your code.

1

solved Using a loop to continue or break the program if condition is met