Jan-19-2018, 10:59 PM
# [ ] use a while True loop (forever loop) to give 4 chances for input of a correct color in a rainbow
# rainbow = "red orange yellow green blue indigo violet"
# rainbow = "red orange yellow green blue indigo violet"
while True: rainbow = "red orange yellow green blue indigo violet" try1 = input("try color: ") try2 = input("try color: ") try3 = input("try color: ") try4 = input("try color: ") if try1 in rainbow: print("You guessed the colour!") elif try2 in rainbow: print("You guessed the colour!") elif try3 in rainbow: print("You guessed the colour!") elif try4 in rainbow: print("You guessed the colour!") else: print("Better luck next time!")I assume that this is not optimal solution. I at first tried with if try1 or try2 or try3 or try4 in rainbow: but that doesn't work. Advice is appreciated.