1

As the title says, how would I go about converting '1,0' into 1,0 I've been getting ValueError: invalid literal for int() with base 10: '1,0'

2 Answers2

1

First of all, 1,0 is generally not valid syntax for a float. You have to use 1.0. Second you can't convert 1.0 to an int, as this is a float. Use float("1.0") instead. If you need an int you can round the parsed float, e.g.

round(float("1.0"))
Erich
  • 1,838
  • 16
  • 20
0

you can use:

int(float('1,0'.replace(',', '.')))
kederrac
  • 16,819
  • 6
  • 32
  • 55