Advertisement
Sparkster

Untitled

Jul 21st, 2013
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. from random import randint
  2.  
  3. number = randint(1,100)
  4.  
  5. def findnumber():
  6.     guess = input("Guess a number between 1 and 100: ")
  7.     tries = 0
  8.     if guess == number:
  9.         tries += 1
  10.         print "You won!"
  11.         print tries
  12.     elif guess < number:
  13.         print "Guess higher!"
  14.         tries += 1
  15.         findnumber()
  16.     elif guess > number:
  17.         print "Guess lower!"
  18.         tries += 1
  19.         findnumber()
  20.     else:
  21.         pass
  22.  
  23. print findnumber()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement