X=[1,2,1,0,1]
def f(x):
return {1:'car',2:'bike',0:'bus'}.get(x,'default')
for i in X:
print(i)
f(i)
output: 1 2 1 0 1
上述代码的问题是,它不执行函数f(x)
答案 0 :(得分:2)
那呢?证明它执行正常
X=[1,2,1,0,1]
def f(x):
return {1:'car',2:'bike',0:'bus'}.get(x,'default')
for i in X:
print(i)
print(f(i))