On Wednesday 27 July 2016 13:45, Cai Gengyang wrote:

> How to debug this error message ?

Start by reading the message:

invalid literal for int() with base 10: ''

Now try to experiment at the interactive interpreter:

int('45')  # works
int('xyz')  # ValueError: invalid literal for int() with base 10: 'xyz'
int('QWE')  # ValueError: invalid literal for int() with base 10: 'QWE'
int('!@#')  # ValueError: invalid literal for int() with base 10: '!@#'

What do you think int('') will do? Try it and see. Were you right?


> print('You will be ' + str(int(myAge) + 1) + ' in a year.')
> Traceback (most recent call last):
>   File "<pyshell#53>", line 1, in <module>
>     print('You will be ' + str(int(myAge) + 1) + ' in a year.')
> ValueError: invalid literal for int() with base 10: ''

What value do you think myAge has?

Hint: you call int(myAge). That raises ValueError, and says that '' is an 
invalid literal for int. What value do you think myAge must have?


Where does myAge get its value from?


-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to