myAge = input()
print('you will be ' + str(int(myage) + 1) + 1 'in a year')
This code always returns:
invalid line base 10.
How can I correct this error?
Whenever you are parsing a string as integer by using int(), make sure that the string contains a valid number and no invalid characters. For example, if you give 23a as input, the invalid a character will cause the error that it is not a valid literal for int base 10.
The code works fine for me, apart from the small typo you have in the code just before the string 'in a year' (there should not be 1). And also, myage and myAge are different.
>>> myAge = input()
>>> print('you will be ' + str(int(myAge) + 1) + ' in a year')
This works fine.
myAge=input("Enter your Age: ") #asks for input
myAge = int(myAge)+1 #converts myAge into an integer and adds one
print("You will be "+str(myAge)+" in a Year") #converts back myAge into a str and prints it
OUTPUT
Enter your Age: 79
You will be 80 in a Year