0

User input not defined

I can't test the code on this app so I did it on another app called qpython. Every time it says that whatever input is put in is not defined? Is it because I'm using a list? Thanks in advance print("Guess three colors that I am thinking of!") colors = ["red", "white", "blue"] while True: guess = input(">>> ") if guess in colors: colors.remove(guess) print("Very good! Guess again") if guess not in colors: print("Guess Again!") if len(colors) == 0: print("You guessed all three colors! You win!") break # Still working on this code

15th Aug 2018, 1:24 AM
Priscilla Monek
Priscilla Monek - avatar
4 Respostas
+ 2
It works for me. You can test it on Sololearn. Give all input at once. On three lines (Or more). Like this. red white blue Then press submit.
15th Aug 2018, 2:15 AM
Paul
Paul - avatar
+ 2
Like this it may work the way you want it to: while True: guess = input(">>> ") if guess in colors: colors.remove(guess) if len(colors) == 0: print("You guessed all three colors! You win!") break else: print("Very good! Guess again") else: print("Guess Again!")
15th Aug 2018, 2:57 PM
Paul
Paul - avatar
+ 1
Which version of qpython are you using? It might be python 2. Your code works on python 3.
15th Aug 2018, 2:21 AM
Paul
Paul - avatar
0
Paul Jacobs oh thank you! I forgot to put all 3 in the input rather than 1 so it does work on there. Now my only question is how can I make it say guess again only for when you guess the first two? I've tried using if guess in colors and if len(colors) > 1: so that it would print "very good guess again, but after you guess the third color, it still says to guess again
15th Aug 2018, 10:53 AM
Priscilla Monek
Priscilla Monek - avatar