[Tutor] Need help with Factorial algorithm using Python
carroll at tjc.com
Fri Sep 5 07:24:55 CEST 2008
On Thu, 4 Sep 2008, Robert Berman wrote:
> Time to do some reading about regex. And here I thought I was slick
> working with lists and strings.
You shouldn't need a regexp for this. An easy way to count the trailing
- convert the number to a string;
- make a copy, stripping off the trailing zeroes, using rstrip('0')
- compare the lengths of the two strings
The difference in the lengths is the number of trailing zeroes.
More information about the Tutor