how many nested for can we utilize?
Patrol Sun
sunp1028 at gmail.com
Mon Aug 18 12:01:17 EDT 2008
Thanks, I cannot utilize the String Class completely. I'm a newbie for
python
2008/8/18 Gabriel Genellina <gagsl-py2 at yahoo.com.ar>
> En Sun, 17 Aug 2008 21:57:46 -0300, Patrol Sun <sunp1028 at gmail.com>
> escribió:
>
> > Of course We needn't 100 levels,but I use the exec function can concise
> the
> > code. See the attachment.
>
> Just a note on the attached code:
>
> def isPro52Num(n):
> s=[]
> for i in range(1,7):
> s.append(str(i*n))
> for i in s[0]:
> ll = len(string.join(string.split(s[0],i),''))
> for j in range(1,6):
> if ll!=len(string.join(string.split(s[j],i),'')):
> return False
> return True
>
> The functions in the string module have been deprecated ages ago in favor
> of the corresponding string methods.
> In this expression: len(string.join(string.split(s[0],i),'')) if you want
> to get "the number of digits in s[0] that are not i" I think it's way faster
> (and more clear) to do len(s[0])-s[0].count(i) instead of creating two lists
> just to throw them away.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080819/856d9e2c/attachment-0001.html>
More information about the Python-list
mailing list