Running the code below prints hellohello hellohellohello
However, I never specified a parameter to either twice
variable or thrice
variable.
Also, I never assigned 'hello'
to word1
.
How does it return the answer then? How can twice
or thrice
take in a parameter and equate it to word1
?
def echo(n):
"""Return the inner_echo function."""
def inner_echo(word1):
"""Concatenate n copies of word1."""
echo_word = word1 * n
return echo_word
return inner_echo
twice = echo(2)
thrice = echo(3)
print(twice('hello'), thrice('hello'))