Solution for python code plssssss


You have to guess a number between 1 to 10 up to three times. My code works if the user doesn’t guess correctly but there’s an error message if the user guesses it correctly.


from random import randint

Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)

guesses_left = 3

Start your game!

while guesses_left > 0:
guess = int(raw_input("Your Guess: "))
guesses_left -= 1
if guess == random_number:
print "You win!"
print “You lose.”

error message:

Your Guess: 2
Your Guess: 2
Your Guess:
Traceback (most recent call last):
File “python”, line 10, in
ValueError: invalid literal for int() with base 10: ‘’


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.