Hi there,
I have come up with this code, after 4 tries, it is supposed to say "Out of tries" but before it says "Out of tries", it will say "Try again"
Any idea what correction is needed to prevent "Try again" from appearing after the fourth try and have the code say "Out of tries" straight away?
rainbow = "red, orange, yellow, green, blue, indigo, violet"
tries = 0
I have come up with this code, after 4 tries, it is supposed to say "Out of tries" but before it says "Out of tries", it will say "Try again"
Any idea what correction is needed to prevent "Try again" from appearing after the fourth try and have the code say "Out of tries" straight away?
rainbow = "red, orange, yellow, green, blue, indigo, violet"
tries = 0
rainbow = "red, orange, yellow, green, blue, indigo, violet" tries = 0 while True: choice = input("Enter rainbow colour: ") if choice in rainbow: print("Correct") break else: tries += 1 print("Try again") if tries == 4: print("Out of tries") break else: pass