Maybe a stupid idea

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Wed Dec 31 19:08:15 EST 2003


On 31 Dec 2003 09:49:55 -0800, rumours say that sebb at linuxcult.com
(sebb) might have written:

>Here is a simple example :
>
>b=0
>
>while b < 50:
>    b+=1
>    print "*" * b
>
>while b > 0:
>    b-= 1
>    print "*" * b
>
>It takes two while blocks to do a cycle.

Another way to do the above in a single block:

for a in xrange(-49, 50):
	b= 50-abs(a)
	print "*" * b

or the more cryptic (which you really should ignore):

from itertools import imap
for a in imap(50 .__sub__, imap(abs, xrange(-49, 50))):
	print "*" * b

Note that significant space between "50" and "." :)
-- 
TZOTZIOY, I speak England very best,
Ils sont fous ces Redmontains! --Harddix



More information about the Python-list mailing list