How do I call a function twice or more times consecutively?

后端 未结 9 1829
借酒劲吻你
借酒劲吻你 2020-12-05 00:02

Is there a short way to call a function twice or more consecutively in Python? For example:

do()
do()
do()

maybe like:

3*do         


        
9条回答
  •  北海茫月
    2020-12-05 00:24

    You may try while loop as shown below;

    def do1():
        # Do something
    
    def do2(x):
        while x > 0:
            do1()
            x -= 1
    
    do2(5)
    

    Thus make call the do1 function 5 times.

提交回复
热议问题