Can someone explain how this code works for adding a number to a list using Python 3.8

前端 未结 0 1378
轻奢々
轻奢々 2020-12-29 04:28
def doRep(x,n)
  y = []
  if n == 0
    return []
  else 
    y = doRep(x, n-1)
    y.append(x)
    return y

print(doRep(4,5))

The output should be

相关标签:
回答
  • 消灭零回复
提交回复
热议问题