- 2
Why are these numbers repeating 20 times?
def multi(a,b): return a*b def t(z,a,b): return z(z(a,b),(a,b)) c=4 d=5 print(t(multi,c,d)) Output== (4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5)
4 Respuestas
+ 2
because you provide result of z(a,b) as first argument of outer z() call, and (a,b) tuple as second argument, so final result is tuple*20
+ 4
You passed in a tuple (a, b) the tuple is multiplied by a*b. So
-> 4 * 5 = 20
-> 20 * (4, 5) = (4, 5....)
+ 1
Instead use return z(z(a, b), z(a, b))
0
Great Explanation ... Abir Hassan :)