I am trying to allocate a print statement in a variable in one function:
< Code> DEF Nemar (FN, LN = 'Smith'): Value of return, default value R = print is "your name", FN, LN returns R
But when I run the module, it says:
traceback (most recent call final): file "& lt; pyshell # 1"; Line 1, & lt; Module & gt; Import m8 file "m8.py", line 3 r = print "your name is", fn, ln ^ syntax error: invalid syntax
any explanation?
As you noted, in Python 2.x, print
a The statement is a statement is not an object, you can not give it to anything, you can execute it.
Why do you want to return the print
statement? Why not print string or a function, which will be executed when print statement is executed?
No comments:
Post a Comment