Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55363
| References | <0aa3c507-a570-4d39-823d-106ba63b0b70@googlegroups.com> |
|---|---|
| Date | 2013-10-02 12:13 -0500 |
| Subject | Re: Rounding off Values of dicts (in a list) to 2 decimal points |
| From | Skip Montanaro <skip@pobox.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.641.1380733997.18130.python-list@python.org> (permalink) |
> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Rounding off Values of dicts (in a list) to 2 decimal points tripsvt@gmail.com - 2013-10-02 10:01 -0700
Re: Rounding off Values of dicts (in a list) to 2 decimal points Skip Montanaro <skip@pobox.com> - 2013-10-02 12:13 -0500
Re: Rounding off Values of dicts (in a list) to 2 decimal points Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-10-02 20:22 +0300
Re: Rounding off Values of dicts (in a list) to 2 decimal points Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-02 13:19 -0400
Re: Rounding off Values of dicts (in a list) to 2 decimal points Neil Cerutti <neilc@norwich.edu> - 2013-10-02 17:32 +0000
Re: Rounding off Values of dicts (in a list) to 2 decimal points tripsvt@gmail.com - 2013-10-03 10:06 -0700
Re: Rounding off Values of dicts (in a list) to 2 decimal points Peter Otten <__peter__@web.de> - 2013-10-03 19:41 +0200
Re: Rounding off Values of dicts (in a list) to 2 decimal points Neil Cerutti <neilc@norwich.edu> - 2013-10-03 18:03 +0000
Re: Rounding off Values of dicts (in a list) to 2 decimal points tripsvt@gmail.com - 2013-10-03 11:17 -0700
csiph-web