Cast the input data from the user (string base type), into an integer

  Kiến thức lập trình

I have an assignment where I need to cast the input data from the user (string base type), into an integer. I am getting the value error when I do this. Where am I going wrong?

raw_inp=input("enter numerical data")
user_inp=int(raw_inp)
if 1<=user_inp<=100:
    print("Congratulations")
else:
    print("Please enter the value again")

New contributor

Varun Sood is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT