0

I want to give "a" variable different numbers and let the user guess a number, if the number guessed is similar to one of the numbers then print out "correct"

a = 1, 
5, 
10

b = input("Guess one of the numbers: ")

if b == a:
    print("Correct")

else:
    print ("Wrong")
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
4non
  • 35
  • 4

1 Answers1

1

The assignment to a succeeds, but ends with the newline. a is a singleton tuple. a = 1, 5, 10 on one line is the 3-element tuple you want; spread across multiple lines, you need parentheses

a = (1,
5,
10
)

or explicit line continuations

a = 1, \
5, \
10

Once you have the correct tuple, you need to use containment, not equality, to see if b is one of the numbers. You also need to convert the string input to an integer first.

b = int(input("Guess one of the numbers: "))

if b in a:
    print("Correct")

else:
    print ("Wrong")
 
    
chepner
  • 497,756
  • 71
  • 530
  • 681