-2

i dont know why this code not printing 'got it' when i run it it just shows me the prints the else statement , even if the answer is correct.

import random as rand
print('Welcome to the guessing game!')
print('type a number between 1 to 9')
running = True
while running:
    value = rand.randint(1, 9)
    user_guess = input()

    if user_guess == value:
        print('got it')
    else:
        print('not at all')

even ive tried with printing the value to make sure my answer is correct.

Johnny Doe
  • 35
  • 1
  • 7

1 Answers1

0

Because after

user_guess = input()

user_guess will be a str and value is an int.
At statement if user_guess == value: you trying to compare str with int.
Try

user_guess = int(input())
kvorobiev
  • 5,012
  • 4
  • 29
  • 35