Most elegant way to do something N times

Morten W. Petersen morphex at gmail.com
Mon Dec 23 19:16:49 EST 2019


It depends on what's elegant, and beauty is in the eye of the beholder..

def recurse(n):
  print(”do be do be do”)
  if n>0: recurse(n-1)

Regards,

Morten

søn. 22. des. 2019, 21:37 skrev Batuhan Taskaya <isidentical at gmail.com>:

> I encounter with cases like doing a function 6 time with no argument, or
> same arguments over and over or doing some structral thing N times and I
> dont know how elegant I can express that to the code. I dont know why but I
> dont like this for _ in range(n): do() thing. Any suggestions?
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list