Hi all

I want to convert '165.0' to an integer.

The obvious method does not work -

x = '165.0'
int(x)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '165.0'

If I convert to a float first, it does work -

int(float(x))
165


Is there a short cut, or must I do this every time (I have lots of them!) ? I know I can write a function to do this, but is there anything built-in?

Thanks

Frank Millman


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

Reply via email to