Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simple guess the number game
- from random import randint
- def findnumber():
- number = randint(1,100)
- print number
- guess = raw_input("Guess a number between 1 and 100: ")
- tries = 0
- while guess != number:
- if not guess.isalpha():
- print "That is not a number!"
- elif guess < number:
- print "Guess higher!"
- tries += 1
- elif guess > number:
- print "Guess lower!"
- tries += 1
- findnumber()
- else:
- print "You have won!"
- tries += 1
- print "It took you %d tries!" % tries
- print findnumber()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement