在Python中,不用while和for循环遍历列表

a = [1, 2, 3, 8, 9]
def printlist(l, index):
    if index == len(l):
        return
    else:
        print(l[index])
        printlist(l, index + 1)

printlist(a, 0)

*****for和while循环底层用的是递归实现的

猜你喜欢

转载自blog.csdn.net/a289237642/article/details/81146503
今日推荐