In Python ” ValueError: invalid literal for int() with base 10: ‘Enter Year:’ ” we face this error message when we try to convert input() string into integer int() and at the same time we use int() inside input function { input( int() ) } that’s why we face this error. If you want to fix this error so we need to use int (input() ) instead of input( int() ), for more clarification please see the below example.
Wrong Code
print("Welcome To Amol Blog Leap Year Python Code")
year = input(int("Enter Year:"))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("Leap Year")
else:
print("Not Leap Year")
else:
print("Not Leap Year")
else:
print("Not Leap Year")
Error Massage
Traceback (most recent call last):
File "/home/kali/python/webproject/simple_projects/Leap_year/main.py", line 2, in <module>
year = input(int("Enter Year:"))
ValueError: invalid literal for int() with base 10: 'Enter Year:'
Wrong code line
year = input(int("Enter Year:"))
Correct code line
year = int(input("Enter Year:"))
- Wrong action: year = input ( int ( “Enter Year:” ) )
- Correct action: year = int( input (“Enter Year:” ) )
Entire Correct Code line
print("Welcome To Amol Blog Leap Year Python Code")
year = int(input("Enter Year:"))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("Leap Year")
else:
print("Not Leap Year")
else:
print("Not Leap Year")
else:
print("Not Leap Year")
What is ValueError: invalid literal for int() with base 10:?
In Python, we face this error message when we try to convert input() string into integer int() and at the same time we use int() inside the input function { input( int() ) } that’s why we this error shows python.
How to fix ValueError: invalid literal for int() with base 10:?
For this error multiple options or methods are available but one of the simplest ay to fix this error so we need to use int (input() ) instead of input( int() ), for more clarification please see the above example.
For more information Visit YouTube Channel.

