Temmu Well-known member Joined Apr 18, 2012 Posts 436 Location far reaches of the galaxy, but you knew that... Feb 21, 2013 #1 greets! help in resolving this is appreciated. no, it is not homework. i'm a bit old for that. thanks! this file is tryme3.py Code: def three_lines(): print print print def nine_lines(): three_lines() three_lines() three_lines() print "line 1" nine_lines() print "line 10" the output is: >>> tryme3a.py Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'tryme3a' is not defined Click to expand... same output with tryme3a w/o the .py
greets! help in resolving this is appreciated. no, it is not homework. i'm a bit old for that. thanks! this file is tryme3.py Code: def three_lines(): print print print def nine_lines(): three_lines() three_lines() three_lines() print "line 1" nine_lines() print "line 10" the output is: >>> tryme3a.py Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'tryme3a' is not defined Click to expand... same output with tryme3a w/o the .py
Will Senior Administrator Staff member Joined Mar 4, 2012 Posts 8,061 Location %tmp% Feb 24, 2013 #2 There error message you've described is related to something that isn't in the code you've provided. For the error message, in line 1 you've made a call to tryme3a, but Python doesn't know what that means. You're missing a function definition or something similar - probably just a syntax error somewhere. --------- For the actual code above, I get the following error message: Code: Syntax Error: Print is a function - it needs () after it. More info is here. Code: def three_lines(): print() print() print() def nine_lines(): three_lines() three_lines() three_lines() print("line 1") nine_lines() print("line 10") The above code outputs: Read More: Code: line 1 line 10 You could also change the three_lines() function to: Code: def three_lines(): print("\n\n\n") def nine_lines(): etc...
There error message you've described is related to something that isn't in the code you've provided. For the error message, in line 1 you've made a call to tryme3a, but Python doesn't know what that means. You're missing a function definition or something similar - probably just a syntax error somewhere. --------- For the actual code above, I get the following error message: Code: Syntax Error: Print is a function - it needs () after it. More info is here. Code: def three_lines(): print() print() print() def nine_lines(): three_lines() three_lines() three_lines() print("line 1") nine_lines() print("line 10") The above code outputs: Read More: Code: line 1 line 10 You could also change the three_lines() function to: Code: def three_lines(): print("\n\n\n") def nine_lines(): etc...