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

int, python, type-conversion

Solution

The easiest way to first convert to `Decimal`:

from decimal import Decimal
int(Decimal('0.00'))

if you are sure that fractional part is always zero then faster would be to use float

int(float('0.00'))

Problem

I have a string in Python like that: ``` l = "0.00 0.00" ``` And I want to convert it in a list of two numbers. The following instruction does not work: ``` int(l.strip(" \n").split(" ")[0]) ``` Apparently the function `int()` can convert string like `0` or `00` to an int, but it does not work with `0.0`. Is there a way to convert `0.0`? A.

Original source