To make the game more practical (not error)


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/8?curriculum_id=4f89dab3d788890003000096

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!"
        break
    else:
        print "Wrong input"
    guesses_left -= 1
else:
    print "You lose."


#2

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.


#3

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