example: 40286 -> 68204

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Mon Jun 4 00:45:08 EDT 2007


On Jun 3, 5:23 pm, Shihpin <Shihpin.... at gmail.com> wrote:
> Hi all,
>
> Is there a fuction that reverse the digits of a number?
>
> Many thanks,
>
> Shihpin Lin


One can use int, str and a slice:

print int(str(40286)[::-1])

--
Hope this helps,
Steven




More information about the Python-list mailing list