【Python】找规律_01


2 打印 2,3
3 打印 2,3,4
4 打印 2,3,4,5
……依次类推

def test_debug(self, n):
    """
        2 打印 2,3
        3 打印 2,3,4
        4 打印 2,3,4,5
        ……依次类推
    :return:
    """

    if n >= 2:
        i_list = []
        for i in range(1, n+1):
            i_list.append(i+1)
        print("n = {}, 输出:{}".format(n, i_list))
    else:
        print("请输入大于2的正整数")



if __name__ == "__main__":
    print("")
    test_debug(n=3)
    test_debug(n=4)
    test_debug(n=5)
    test_debug(n=8)

 结果: