Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import random
  2. ask='Y'
  3. x=(random.randint(1, 100+1)) #makes random number
  4. print('''Guessing Game
  5. *******************
  6. I’m ready for your guess…''')
  7.  
  8. while ask=='Y' or ask=='y':  
  9.   for run in range(0,4):
  10.     if run==3:
  11.       #if it's the third run, it will tell the user the answer and ask if they want to continue
  12.         print('The number was',x)
  13.         ask=input('Would you like to play again?(Y/N): ')
  14.         x=(random.randint(1, 100+1))#make a new number
  15.         break
  16.     num=int(input('What do you think it is?: '))
  17.     #tells the user if the number is below, above, or equal to the number
  18.     if num>100 or num<0:
  19.         print('enter a number between 1 and 100')
  20.         continue
  21.     if num>x and not(run==2):
  22.         print('Too high! Try again')
  23.     if num<x and not(run==2):
  24.         print('Too low! Try again…')
  25.     if num==x:
  26.         print('You got it!!! You Win!!!')
  27.         ask=input('Would you like to play again?(Y/N): ')
  28.         x=(random.randint(1, 100+1))#make a new number
  29.         break
  30. print('Goodbye')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement