reading a book on python. there’s some example code demonstrating nested scopes. there must be an error with it. i’m not sure how to fix it, not quite sure how it should be.
def multiplier(factor):
def multiplyByFactor(number):
return number*factor
return multiplyByFactor
example use/output of it also out of the book:
>>> double = multiplier(2)
>>> double(5)
10
>>> triple = multiplier(3)
>>> triple(3)
9
>>> multiplier(5)(4)
20
i suppose there should be a parameter in brackets after the multiplyByFactor call, but i’m still unsure what’d properly correct the code. any guesses/ideas?
thanks.