def foo(bar): if bar==1: bar=0 else: bar=1 print bar bar=1 for i in range(10): foo(bar)