python27 - this doesn't work:

Temmu

Well-known member
Joined
Apr 18, 2012
Posts
436
Location
far reaches of the galaxy, but you knew that...
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

same output with tryme3a w/o the .py
 
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:

You could also change the three_lines() function to:

Code:
def three_lines():
    print("\n\n\n")
def nine_lines():
    etc...
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top