I'm reading an exercise out of a Python book, here is what it says:
Modify do_twice so that it takes two arguments, a function object and a value, and calls the function twice, passing the value as an argument.
Write a more general version of print_spam, called print_twice, that takes a string as a parameter and prints it twice.
Use the modified version of do_twice to call print_twice twice, passing 'spam' as an argument.
Heres what I wrote:
def do_twice(f, g):
f(g)
f(g)
def print_spam(s):
print (s)
do_twice(print_spam('lol'))
What is the way it is supposed to be written? I'm totally stumped on this one.