Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Write your code here
- from random import randint
- guess = False
- user = 0
- count = 0
- ans = randint(1, 100)
- print('---------------------------------------------')
- print("I am thinking of a number between 1 and 100.")
- print("Can you guess what the number is?")
- print('---------------------------------------------')
- while guess == False:
- user = int(input("Enter your guess: "))
- if user < 0 or user > 100:
- print('You have entered an invalid integer')
- else:
- if user == ans:
- count += 1
- print("You guessed it in %d guesses!" % (count))
- print('---------------------------------------------')
- break
- if user >= (ans - 10) and user <= (ans + 10):
- count += 1
- print('hot')
- print('---------------------------------------------')
- elif user < ans or user > ans:
- count += 1
- print('cold')
- print('---------------------------------------------')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement