How do i resolve this error?
Invalid literal for int with base 10
Hello @gunjanarora, the way you have taken the input is incorrect.
The 1 10 denotes that the input taken is in the single line. So you need to take, lower,upper = map(int,input().split())
Pls, try this out and if it doesn’t work pls let me know.
Thanks
The error message invalid literal for int() with base 10 would seem to indicate that you are passing a string that’s not an integer to the int() function . In other words it’s either empty, or has a character in it other than a digit. You can solve this error by using Python isdigit() method to check whether the value is number or not. The returns True if all the characters are digits, otherwise False .
val = "10.10"
if val.isdigit():
print(int(val))
Python2.x and Python3.x
Sometimes the difference between Python2.x and Python3.x that leads to this ValueError: invalid literal for int() with base 10 .
With Python2.x , int(str(3/2)) gives you “1”. With Python3.x , the same gives you (“1.5”): ValueError: invalid literal for int() with base 10: “1.5”.