Function of "return" in loop


Actually, I understand the exercise, but I have a question about the "loop" . Please see the example in this lesson.

What does " return total " play in the "loop"? Since "for .... in ...." loop has already operated every item in the list, it can repetitively play the item in the list. So what will be the result if there is no "return total" in the end?

no code, just question about the example


well, the loop will stop eventually since it will run out of items.

then nothing would happen, since you don't do anything with total.

With such questions, it is still nice to include code so we can see it, this really helps to help you :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.