[Tutor] Pythonwin

Gregor Lingl glingl@aon.at
Wed Dec 11 21:32:03 2002


Scott Widney schrieb:

>Aren't you glad that the batteries are included! From eleven lines to three:
>
>  
>
>>>>L, X = [1,2,4,8,16,32,64], 5
>>>>if L.index(2**X): print "found at", L.index(2**X)
>>>>        
>>>>
>... else: print X, "not found"
>... 
> found at 5
>  
>
A little too short cut:

 >>> L, X = [1,2,4,8,16,32,64], 0
 >>> if L.index(2**X): print "found at", L.index(2**X)
else: print X, "not found"

0 not found

whereas
 >>> 2**0
1

and what, when
 >>> L, X = [1,2,4,8,16,32,64], 7
?
Regards, Gregor




>
>Scott
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>  
>