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
- tries = 0
- guess = 1
- while guess != number:
- guess = raw_input("Guess a number between 1 and 100: ")
- if guess < number:
- print "Guess higher!"
- tries += 1
- elif guess > number:
- print "Guess lower!"
- tries += 1
- 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