Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- print("Let's play a number guessing game")
- print("I'll select a number and you'll guess it")
- print("Hint: it is between 1 and 100 XD")
- print("Let us start :)")
- number = random.randint(1, 100)
- while True:
- try:
- guess = int(input("What is your guess? "))
- except ValueError:
- print("Sorry, only numbers. Let's try again.")
- continue
- difference = abs(number - guess)
- if difference == 0:
- print("Yay! You've guessed it correctly!!")
- break
- if difference <= 4:
- guess = print("Very close! Let's try again.")
- elif difference <= 9:
- guess = print("Hot! Let's try again.")
- else:
- guess = print("Cold! Let's try again.")
Advertisement
Add Comment
Please, Sign In to add comment