"normalizing" a value

Paul Rubin no.email at nospam.invalid
Wed Jul 1 20:36:21 EDT 2015


bvdp <bob at mellowood.ca> writes:
>    while x < 0: x += 12
>    while x >= 12: x -= 12
> Okay, that works. Just wondering if there is an easier (or faster) way
> to accomplish this.

x = x % 12

should be the same as the above.  But are you sure that's really what
you want?



More information about the Python-list mailing list