SHARE
TWEET

Untitled

a guest Jul 15th, 2012 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. def main():
  3.     while True:
  4.         request = str(input('Play? [y/N]: '))
  5.         if 'y' in request.lower():
  6.             phase2()
  7.         elif 'n' in request.lower():
  8.             break
  9.         else:
  10.             print('Invalid Value')
  11.             main()
  12.  
  13. def phase2():
  14.     answer = random.randrange(0, 100)
  15.     start = 0
  16.     while (start < 6):
  17.         print ('You only have 5 chances (number is in between 0 - 100)')
  18.         print ('Attempt', start)
  19.         retry = int(input('Guess:> '))
  20.         start += 1
  21.         if retry < answer:
  22.             print ('A little higher')
  23.         elif retry > answer:
  24.             print ('A little lower')
  25.         elif retry == answer:
  26.             print ('Congrats')
  27.         else:
  28.             print ('Invalid Input')
  29.        
  30. main()
  31.  
  32. #k3y
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top