19th Mar 2021, 10:30 AM
CITRRUS _
CITRRUS _ - avatar
2 odpowiedzi
0
what is the goal of this code? 'text' function takes no arguments and call return a list of words... 'caps' function takes one argument and return a function ('wrap') wich takes no arguments... and return a list from the 'caps' argument (wich so should be iterable)... x = caps(text()) first call 'text', then call 'caps' with returned value of 'text' call as argument... so 'x' contains now the 'wrap' function... print(x) output the value of x, wich is a function dynamically build... maybe you want to rather do: print(x()) wich output result of 'x' ('wrap') call... but this will output: ['Hello', 'world'] None 1st line is printed from inside 'wrap' function (using the argument provided to 'caps' call), while 2nd line is the result of 'wrap' call (wich doesn't return anything, that's why you get None)... ... so it sounds like a decorator (but missused), as if you only want to print the words list generated by 'text', you simply could do: print(text()) or even less simply: x = caps(text()) x()
19th Mar 2021, 11:11 AM
visph
visph - avatar
0
Here's the fix for you https://code.sololearn.com/c5HAL1Wg67GC/?ref=app And the mistake you have done is you tried to print print function which calla many object that won't return string or list . To make it clear what you do is ```python print(print("this is the real")) ``` or ```python print(do_a_fake_print("this is fake")) #take the below function as 'print' def do_a_fake_print(d):#this is not returning primitive data type #which print is only capable of primitive unless it would print the instance of the object Foo._start_printing() print(d) ```
19th Mar 2021, 11:08 AM
Ananiya Jemberu
Ananiya Jemberu - avatar