Invalid literal for int() with base 10?

Chris Angelico rosuav at gmail.com
Thu May 25 20:28:22 EDT 2023


On Fri, 26 May 2023 at 10:26, Kevin M. Wilson via Python-list
<python-list at python.org> wrote:
>
> Ok, I'm not finding any info. on the int() for converting a str to an int (that specifies a base parameter)?! The picture is of the code I've written... And the base 10 paradigm involved?? years = int('y') # store for calculation ValueError: invalid literal for int() with base 10: 'y'
>

Imagine giving this to a human. "How many years did you say?" "Oh, y years."

Is that a reasonable way to say a number of years? No. It's an invalid
way of specifying a number of years. Python is a little more technical
in the way it describes it, but the fact is unchanged.

ChrisA


More information about the Python-list mailing list