Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 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:
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:
print("Error, please check input.")
continue
print("Thanks for playing Guess the Number.")
print("I hope I can see you soon!")