Why the place of " return" is important?


#1



I would like to know how these three cases are different. Thank you!


for numbers in lists:
        for i in numbers:
            results.append(i)
return results

for numbers in lists:
        for i in numbers:
            results.append(i)
        return results

for numbers in lists:
        for i in numbers:
            results.append(i)
            return results


#2

In this case, return is not even expected.


#3

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