How to catch StopIteration?

2008-06-16 Thread ccy56781
I'm writing to see calcuration process. And so, I can't catch StopIteration... What is mistake? def collatz(n): r=[] while n>1: r.append(n) n = 3*n+1 if n%2 else n/2 yield r for i, x in enumerate(collatz(13)): try: last = x[:i+1] print x[:i+1] except StopIteration:

Conjunction List

2008-05-31 Thread ccy56781
http://codepad.org/MV3k10AU I want to write like next one. def conjunction(number=a[1],name=b[1],size=c[1]): flag = a[0]==b[0]==c[0] if flag: for e in zip(number,name,size): print e conjunction(a,b,c)