-1

I'm recreating the Mastermind game and I'm stuck on some "if" statements i am trying make it tell the user that if the color is not the same as in guess1but is the proper color is guess2 it will print "guess 1 right color wrong position"

Python V- 2.7.8

colors =  ('R','B','G','P','Y','O')
Color1 = random.choice(colors)
Color2 = random.choice(colors)
Color3 = random.choice(colors)
Color4 = random.choice(colors)
guess1 = raw_input("First Color: ") 
guess2 = raw_input("Second Color: ")
guess3 = raw_input("Third Color: ")
guess4 = raw_input("Fourth Color: ")
guesses = (guess1,guess2,guess3,guess4)
Allcolors = (Color1,Color2,Color3,Color4)

if guesses == Allcolors:
        print "All colors are correct!"
    if guesses != Allcolors:
####
        if guess1 == Color2 or Color3 or Color4:
            print "Guess 1 right color wrong position"
        if guess1 == Color1:
            print "Color 1 is correct"
####
        if guess2 == Color2:
            print "Color 2 is correct"
        if guess3 == Color3:
            print "Color 3 is correct"
        if guess4 == Color4:
            print "Color 4 is correct"
Carlos
  • 5,991
  • 6
  • 43
  • 82
Tyrell
  • 896
  • 7
  • 15
  • 26
  • Is the indentation here identical to the indentation of your local code? If so, see how you'll never have both `guesses == Allcolors` and `guesses != Allcolors` – Patrick Haugh Nov 30 '17 at 16:18

1 Answers1

0
if guess1 == Color2 or Color3 or Color4:

This doesn't work. You have to repeat the variable:

if guess1 == Color2 or guess1 == Color3 or guess1 == Color4:

You can also use in operator to look in a container:

if guess1 in (Color2, Color3, Color4):
nosklo
  • 217,122
  • 57
  • 293
  • 297