This simple one line code is running for more than 1 minute and showing this error.
I have installed jupyter notebook in VS code and using miniconda instead of anaconda...I couldn't get the issue.
The 2 line code is:
my_number = int(input("enter a number: "))
print(my_number)
Error:
ValueError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_10048/2282921608.py in <module>
----> 1 my_number = int(input("enter a number: "))
2 print(my_number)
ValueError: invalid literal for int() with base 10: ''
CodePudding user response:
You should enter an integer number instead of a string. If you entered a sting on the input then the int keyword can't convert the string. So, use an integer number to get rid of this problem.
CodePudding user response:
Your problem is: The my_number value is a floating point. Example: 1500.0000
A simple fix would be:
my_number = int(float(input("enter a number: ")))
If the number is 35.6573
the result will be 35
The number can only be an int!