Float in Python

Solved
Hello,

I have a small problem in Python when I write (in a loop on i and ii):
float(lignes[i].strip().split(" ")[ii]), it doesn't return anything,

with lignes[i].strip().split(" ")[ii] being a string containing decimal numbers.

Is it because there are commas instead of points in my string that it doesn't work or is it for another reason?

Thank you in advance
Configuration: Windows XP Internet Explorer 6.0

1 answer

  1. Contributor
    Hello,
    Indeed, if you convert a number that is not a float, it won't work.
    You can replace commas with points by doing:
    float(lignes[i].strip().split(" ")[ii].replace(',','.'))

    Best regards
    --

    Google is your friend
    8
    1. Thank you very much,

      Indeed, it works better!

      ++
      0