Python: Incident causing wrong result? -
the following code expected return 'none', however, seems i've done wrong incident:
def function_that_prints(): print "i printed" f1 = function_that_prints() print f1 i've tried putting 3rd line left aligned it's still not happening. please correct me, thanks!
with third line indented part of function, function_that_prints() recurses (it calls itself) indefinitely , python raise runtimeerror complaining maximum recursion depth has been exceeded.
if not indent third line have following code snippet:
def function_that_prints(): print "i printed" f1 = function_that_prints() print f1 # running produce: # printed # none the statement f1 = function_that_prints() print "i printed" , set f1 none, suggested.
then statement print f1 print value of f1, none.
Comments
Post a Comment