return vs print list

后端 未结 2 484
情深已故
情深已故 2020-12-03 19:17

Very new to programming.
Wondering why does this example print all the items in the list, while the second example prints only the first?

def list_functi         


        
2条回答
  •  春和景丽
    2020-12-03 20:01

    For functions return terminates the execution, therefore nothing will be executed after return.

    In your case the first function will print all the items because there is nothing that breaks the process. However in the second function it will return and end the process.

提交回复
热议问题