I have written a program and at the end I have written a code for the user to rate my program, but it has some issues please help:
while True:
RR = input("What would you rate this program(?/5): ")
if RR.isnumeric:
rating = int(RR)
if rating >= 5:
print("Looks like you are highly satisfied with this program :D")
break
elif rating == 4 or rating == 3:
print("Ohh! Next time I'll try my best to change this '",rating,"' into 5 ;D")
break
elif rating == 1 or rating == 2:
print("I am sorry if I wasn't good, I'll try my best next time :|")
break
else:
print("Invalid Rating, Try again...")
continue
Result
What would you rate this program(?/5): g
ValueError: invalid literal for int() with base 10: 'g'
What I want is that if someone enters a text instead of a number then it tells that it's an invalid input and continues the loop. How can I get this?
str.isnumericis a function.str.isnumericis alwaysTrueas it checks if it is a truthy value and function object are always truthy. You want to add the()to actually execute the function. Fixed:if RR.isnumeric():