我正在尝试执行以下CodingBat问题:no_teen_sum但在第2行中遇到错误:
def no_teen_sum(a, b, c):
teens = [13,14,17,18,19]
if a in teens:
return b + c
elif b in teens:
return a + c
elif c in teens:
return a + b
elif a in teens and b in teens:
return c
elif a in teens and c in teens:
return b
elif b in teens and c in teens:
return a
答案 0 :(得分:1)
存在缩进问题。记住要始终使用4个空格进行缩进,保持一致。
这是固定版本:
def no_teen_sum(a, b, c):
teens = [13,14,17,18,19]
if a in teens:
return b + c
elif b in teens:
return a + c
elif c in teens:
return a + b
elif a in teens and b in teens:
return c
elif a in teens and c in teens:
return b
elif b in teens and c in teens:
return a