Error with int()

maxm maxmcorp at worldonline.dk
Sat Sep 29 16:45:24 EDT 2001


"Arturo Pérez Mulas" <arturo_perez at wanadoo.es> wrote in message

> I am running python 2.1.1 under Windows XP BETA, and get the following
> error:
>
> >>> int('a')

You cannot make an int from a string that doesnt represent a legal number.

>>> a=2
>>> int(a)
2
>>> a='2'
>>> int(a)
2
>>> int('2')
2
>>> int('somestringWontWork')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
ValueError: invalid literal for int(): somestringWontWork

regards Max M






More information about the Python-list mailing list