Consider I have the below list of float values. I import the locale United States to convert my comma decimal separator to dot decimal values. I cannot use the float format function before i convert it into dot values, since python don't accept comma values as float values. And when i also tried to use the float format function after i get the tuple of dot values, I wont be able to do so because tuples are immutable. I am need of all the tuple float values with a decimal precision of 2. It will be really great if someone can help me with it.
b=['1,374', '6,978', '3,987']
expected output :
b=((1.37), (6.97), (3.98))
Here is my code with output at every line
b= [(x,) for x in b]
output:
b=[('1,374', '6,978', '3,987')]
import locale
locale.setlocale(locale.LC_ALL,'English_United States.1252')
'English_United States.1252'
b=tuple(tuple(locale.atof(e.replace(',', '.')) for e in t) for t in b)
output:
b=((1.374), (6.978), (3.987))