for-case loop evaluates second iteration twice and skips third iteration
So i have this code:
def Convert(ama,a):
print ama,a
def run():
z=0
while z!=3:
z+=1
开发者_JS百科if z==1:
n='e'
if z==2:
n='B'
if z=='3':
n='G'
a='-----2-----5-6----7'
Convert(a,n)
run()
The result:
-----2-----5-6----7 e
-----2-----5-6----7 B
-----2-----5-6----7 B
Although the result I expected was:
-----2-----5-6----7 e
-----2-----5-6----7 B
-----2-----5-6----7 G
Please help.
if z=='3':
should be this
if z==3:
精彩评论