[Tutor] Need to convert 1,987,087,234,456 to an int

John Fouhy john at fouhy.net
Thu Aug 16 04:57:27 CEST 2007


On 16/08/07, Dick Moores <rdm at rcblue.com> wrote:
> That's cool! However, it doesn't solve the problem in my original post.
>
>  >>> t = 1,987,087,234,456
>    File "<input>", line 1
>      t = 1,987,087,234,456
>                  ^
> SyntaxError: invalid token

Hmm, yes.  Any integer starting with a 0 is octal, which means that
using '8' or '9' is a syntax error.  Also, even if you don't get the
syntax error, the numbers will come out differently.

>>> decomma(1,024)
120

It'll be fixed in Python 3000 :-)

-- 
John.


More information about the Tutor mailing list