Re: example: 40286 -> 68204

2007-06-04 Thread Shihpin
Thanks Steven, I will try to decipher that. Shihpin On 6 4 , 1:45, [EMAIL PROTECTED] wrote: > On Jun 3, 5:23 pm, Shihpin <[EMAIL PROTECTED]> wrote: > > Is there a fuction that reverse the digits of a number? > One can use int, str and a slice: > > print int(str(40286)[::-1]) > > -- > Hope this

Re: example: 40286 -> 68204

2007-06-03 Thread attn . steven . kuo
On Jun 3, 5:23 pm, Shihpin <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/pyth

Re: example: 40286 -> 68204

2007-06-03 Thread Shihpin
Brian, Thanks! I will try it when I come home, > > Shihpin Lin > > This does it: > > def reversed_int(i): > > ... return int(''.join(reversed(str(i > > ... > reversed_int(12345) > > 54321 > > Best, > > Brian vdB -- http://mail.python.org/mailman/listinfo/python-list

Re: example: 40286 -> 68204

2007-06-03 Thread Yongjian Xu
Don't think there is one in builtin for that and might have to convert str <-> int to do that too, such as int(str(i)[::-1]) ... Jim On 6/3/07, Shihpin <[EMAIL PROTECTED]> wrote: Hi all, Is there a fuction that reverse the digits of a number? Many thanks, Shihpin Lin -- http://mail.python.

Re: example: 40286 -> 68204

2007-06-03 Thread Brian van den Broek
Shihpin said unto the world upon 06/03/2007 08:23 PM: > Hi all, > > Is there a fuction that reverse the digits of a number? > > Many thanks, > > Shihpin Lin > This does it: def reversed_int(i): > ... return int(''.join(reversed(str(i > ... reversed_int(12345) > 54321

example: 40286 -> 68204

2007-06-03 Thread Shihpin
Hi all, Is there a fuction that reverse the digits of a number? Many thanks, Shihpin Lin -- http://mail.python.org/mailman/listinfo/python-list