I have a list which contains values, and I have another list which contains the corresponding number of decimal places that I would like those numbers rounded to.
values = [0.7065099901199341, 128.7489971923828, 1.0810200233459473]
decimalplaces = [5, 3, 5]
so for example i want the first value rounded to 5 decimal places, the second to 3, and the third to 5.
What I would like to get as an output is [0.70650, 128.749, 1.08102].
I have tried the following:
roundedvalues = [round(int(x),int(y)) for x in values for y in decimalplaces]
But instead i'm getting the following:
>> print(roundedvalues)
>>>[0, 0, 0, 128, 128, 128, 1, 1, 1]
What I would like to get as an output is [0.70650, 128.749, 1.08102].
Many thanks in advance for your help!