Need some help...

Ricardo Aráoz ricaraoz at gmail.com
Fri Nov 2 11:24:35 CET 2007


Gabriel Genellina wrote:
> En Thu, 01 Nov 2007 20:12:52 -0300, Ricardo Aráoz <ricaraoz at gmail.com>  
> escribió:
> 
>>>>>>> def sumToOneDigit(num) :
>>>> 	if num < 10 :
>>>> 		return num
>>>> 	else :
>>>> 		return sumToOneDigit(sum(int(i) for i in str(num)))
>>>>
> 
> def sumToOneDigit(num):
>      return num % 9 or 9
> 
> Valid when num>=1, which is guaranteed by the OP context.
> 

Beautiful. Much better than mine.




More information about the Python-list mailing list