Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Question Number 2 - printTwice (http://www.programmingforums.org/showthread.php?t=14602)

blake_jl Nov 27th, 2007 1:18 AM

Question Number 2 - printTwice
 
I'm back with another simple question.

I won't dwell over this like I did the last one. I'd just like to know why the author of the book I've been reading says

:

printTwice(5)

Gives the result

5 5

He has a few different examples all to do with the printTwice call but when I try and do it, it says

:

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
NameError: name 'printTwice' is not defined


Thanks.

ZenMasterJG Nov 27th, 2007 4:38 AM

Re: Question Number 2 - printTwice
 
Because, presumably, you haven't defined printTwice in that script / interactive session. My guess is you're reading a bit too fast and missed something like:

:

def printTwice(arg):
    print arg
    print arg


blake_jl Nov 27th, 2007 4:44 AM

Re: Question Number 2 - printTwice
 
Quote:

Originally Posted by ZenMasterJG (Post 137611)
Because, presumably, you haven't defined printTwice in that script / interactive session. My guess is you're reading a bit too fast and missed something like:

:

def printTwice(arg):
    print arg
    print arg


Yes you are correct.

Thanks for that. Not sure how I missed it but I thought it was like "print" but just printed it twice instead of once.

Thanks again.


All times are GMT -5. The time now is 3:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC