[Tutor] New function and 3 line program not working?

Liam Clarke cyresse at gmail.com
Wed Nov 10 14:34:56 CET 2004


You need to have in your file line.py the 

def newLine():
         print

before the next one. If you just do it in IDLE, IDLE executes it, but
it doesn't save it anywhere your programme can access it, so your
programme line.py has no idea what newLine() is.


So, line.py should look like this - 

def newLine():
     print
     return

print First Line."
newLine()
print "Second Line."


Hope that helps.

Liam Clarke
On Wed, 10 Nov 2004 08:24:13 -0500, SunDragon <sundragon at cogeco.ca> wrote:
>  
>  
> This is my first post, so HI all! and Thank You for you help! 
>   
> Below is a tutorial that I am trying to complete, but I can not duplicate
> this exercise in either the IDLE gui or command line. (ver 2.3.4)
> Tutorial says to do this.... 
>   
>  define the new function---- I go to IDLE gui and define the function.... 
> 
> def newLine():
>      print 
> 
>   
> write the 3 line program---- I go open another IDLE window and like in the
> tutorial type this 3 line program....
> 
> print "First Line."
> newLine()
> print "Second Line."
> 
> I save it as line.py
> 
> Now I am to see this output result upon running it.... 
> 
> First line.
> 
> Second line. 
> 
> But I dont get the output I should, I get the First Line. printed and a
> syntax error
> 
> >>> 
> First Line.
> 
> Traceback (most recent call last):
> File "C:/Python23/newLine.py", line 2, in -toplevel-
> newLine()
> NameError: name 'newLine' is not defined
>

-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list