Is there a way to subtract 3 from every digit of a number?

Grant Edwards grant.b.edwards at gmail.com
Sat Feb 20 13:42:27 EST 2021


On 2021-02-20, Dan Stromberg <drsalists at gmail.com> wrote:

> Convert to a str.
> Convert to a list of ints, one for each digit
> Add 7 mod 10, for each digit in the list

I'd probably subtract 3 (mod 10), so as to more obviously match the
stated requirement.

> Convert to a list of single-character str's
> Catenate those str's back together
> Convert to a single int




More information about the Python-list mailing list