To make the game more practical (not error)


I want to make the game more practical that
to limit the raw input into only integer within range (1, 11).
If the input is not integer or integer not in range (1,11), to print "Wrong input" and to ask for another correct input again without decrementing guess number

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 :
    print guesses_left
    guess = int(raw_input("Your guess: "))
    if guess guess == random_number :
        print "You win!"
        print "Wrong input"
    guesses_left -= 1
    print "You lose."


You can do that in the last lesson in the exercise, for now, just follow the instructions as they are for now or the lesson checker won't let you past the exercise.


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