def function question

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

Image 1 is the problem and Image 2 is the correct answer.

def multiples(n, m):
    for i in range(1,m+1):


I did it like this, but why isn't it working?


2022-09-20 10:22

2 Answers

Answer the meaning and role of return in the function definition. You may find out for yourself as you try to answer that.

I think you pointed out that I didn't use the return function even though I used the definition, so I did not call the function value.

Does return serve as "call function value"? Answer this question.

2022-09-20 10:22

I'll put a spoon on your explanation.

Look at the following example and think about the difference between the given code and the code you made.

a, b, c = 1, 2, 3
print(a, b, c)
>> 1 2 3
d, e, f = 1
print(d, e, f)
>> Traceback (most recent call last):
    d, e, f = 1
TypeError: cannot unpack non-iterable int object

2022-09-20 10:22

If you have any answers or tips

© 2022 pinfo. All rights reserved.