#import the random package
import random
# This is to check wheter number is negative or not.
def non_zero(data):
try:
while True:
data1 = int(input(data))
if data1 <= 0:
pass
else:
break
except ValueError:
non_zero(data)
else:
print("else blockdata:",data1)
return data1
#This function will verify the guess and random number
def guess(gue_num,ran_num):
while True:
if gue_num < ran_num:
print("Too small!")
gue_num = non_zero("Guess: ")
elif gue_num > ran_num:
print("Too large!")
gue_num = non_zero("Guess: ")
else:
print("Just Right!")
break
inp_data = non_zero("Level: ")
ran_data = random.randint(1,inp_data)
gue_data = non_zero("Guess: ")
guess(gue_data,ran_data)
For the above program, I am giving the input "cat", again the prompt will ask for the level then i am giving the integer value. its throwing the type error. please help me out.