Rounding off Values of dicts (in a list) to 2 decimal points

Skip Montanaro skip at pobox.com
Wed Oct 2 13:13:08 EDT 2013


>     def roundingVals_toTwoDeci():
>         global y
>         for d in y:
>             for k, v in d.items():
>                 v = ceil(v*100)/100.0
>         return
>     roundingVals_toTwoDeci()
>
>
>
> But it is not working - I am still getting the old values.


You're not assigning the rounded value back into d. After assigning to
v try this:

    d[k] = v

Skip



More information about the Python-list mailing list