Share Pastebin
Guest
Public paste!

ln

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 0.59 KB | Hits: 30 | Expires: Never
Copy text to clipboard
  1. #generates a random number from 1 to 100
  2. import random
  3. secret = random.randint(1,100)
  4. tries = 5
  5. z = 0
  6.  
  7. print("Hi! You have 5 tries to guess a number between 1 and a hundred.")
  8. a = 0
  9. while tries > 0 and secret != a:
  10.     a = input("Whats your guess?")
  11.     if  a < secret:
  12.         print("Too low! Try again!")
  13.         tries -= 1
  14.     elif a > secret:
  15.               print("Too high! Try again!")
  16.               tries -= 1
  17.     while tries == 0:
  18.         print("too many tries!")
  19.        
  20.        
  21.    
  22.  
  23. if secret == a:
  24.     print("winner!")
  25.  
  26. else:
  27.               print ("YOU LOSE!!")