Count to zero then Count up

前端 未结 2 1248
长发绾君心
长发绾君心 2020-12-22 14:20

Since im fairly new to python and programming i have a question of a very basic nature. I want to make a iteration function and a recursive function that does this:

2条回答
  •  星月不相逢
    2020-12-22 15:02

    If you can use range, I would do it like this in Python 2.7:

    f = lambda x : map(abs, range(-x,x+1))
    for x in f(4):
        print x,
    

提交回复
热议问题