I'm creating a function that receives a number between 1 and 5 (likert scale), from a question. When the user inputs a wrong INT my loop is ok, the question repeats. But i want the question to repeat if the user inputs a string too. But in that case the program crashes "ValueError: invalid literal for int() with base 10"
def likert(msg):
while True:
L = int(input(msg))
if 1 <= L <= 5 and type(L) == int:
return L
elif L < 1 or L > 5:
print('\033[031mError [1 to 5] only\033[m')
continue