>>> def guess_the_number():
import random
n=input("Enter name: ")
print("Welcome to Guess the Number", n+"!")
print("I will think of a number between 1 to 10.")
print("Can you guess what that number will be?")
x=random.randint(1, 10)
while True:
try: #"Proofing" the code in case of unrecognized input
y=input("Enter number: ")
y=int(y)
if y==x:
print("Congratulations!")
break
elif y<1:
print("Error, out of range.")
continue
elif y>10:
print("Error, out of range.")
continue
elif y==x+1:
print("Close!")
continue
elif y==x-1:
print("Close!")
continue
elif y>x:
print("Too big")
continue
elif y<x:
print("Too small")
continue
except: #Message for when the input isn't recognized by the program
print("Error, please check input.")
continue
print("Thanks for playing Guess the Number.")
print("I hope I can see you soon!")