0

Hi, what's wrong with this code? Because it print wrong for all guesses.

Generate a random number between 1 and 10. Ask the user to guess the number and print amessage based on whether they get it right or not From random import randint a=eval(input(guess a number:)) random_number=randint(1,10) If a==random_number: Print("right") else: Print("wrong")

15th Feb 2022, 12:02 PM
hasti zanganeh
hasti zanganeh - avatar
3 odpowiedzi
+ 1
the code works idk what u mean you could write another elif to check if the user is close
15th Feb 2022, 12:26 PM
Ion Kare
Ion Kare - avatar
+ 2
Because, the generated random number never equal to a. Keep trying, it returns right sometimes.
15th Feb 2022, 12:25 PM
Simba
Simba - avatar
15th Feb 2022, 12:24 PM
Ion Kare
Ion Kare - avatar