第11398题 单选题
爬楼梯问题Python实现中空缺处应填入哪段代码?

爬楼梯游戏需要爬n阶到达楼顶,规定每次只能爬1个或2个台阶,计算共有多少种不同的爬楼方法。小明用Python编写了如下不完整代码,请问哪个选项填入空缺后能得到正确结果?

def fun(n):
    if n in (1, 2):
        return n
    f1, f2, res = 1, 2, 0
    for i in range(3, n+1):
        __________
    return res
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析