Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- ask='Y'
- x=(random.randint(1, 100+1)) #makes random number
- print('''Guessing Game
- *******************
- I’m ready for your guess…''')
- while ask=='Y' or ask=='y':
- for run in range(0,4):
- if run==3:
- #if it's the third run, it will tell the user the answer and ask if they want to continue
- print('The number was',x)
- ask=input('Would you like to play again?(Y/N): ')
- x=(random.randint(1, 100+1))#make a new number
- break
- num=int(input('What do you think it is?: '))
- #tells the user if the number is below, above, or equal to the number
- if num>100 or num<0:
- print('enter a number between 1 and 100')
- continue
- if num>x and not(run==2):
- print('Too high! Try again')
- if num<x and not(run==2):
- print('Too low! Try again…')
- if num==x:
- print('You got it!!! You Win!!!')
- ask=input('Would you like to play again?(Y/N): ')
- x=(random.randint(1, 100+1))#make a new number
- break
- print('Goodbye')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement