[Tutor] Can't figure out why this is printing twice

Alan Gauld alan.gauld at btinternet.com
Mon Jun 8 16:11:05 CEST 2009

"Mike Hoy" <hoym74 at gmail.com> wrote

>I have the following code:

Is this in a file or are you typing it at the python
interpreter >>> primpt?

> import gzip
> import datetime
> date = datetime.date.today()
> name = date.strftime('%m-%d-%Y')+'.gz'
> date.strftime('%m-%d-%Y')+'.gz'
> print "The name of the file will be", name

If its in a file you should only get one print
If its at the >>> prompt you should get a string after
the second call to date.strftime and then your print.

> the output is:
> The name of the file will be
> The name of the file will be 06-08-2009.gz
> I can't figure out why 'The name of the file will be' is printing twice. 
> Any
> help appreciated.

If that is what you get then me neither!

Alan G. 

More information about the Tutor mailing list