[Tutor] print output

Alan Gauld alan.gauld at btinternet.com
Thu Apr 16 23:23:13 CEST 2009


"mbikinyi brat" <mbikinyi_brat at yahoo.com> wrote 
> I have defined variables as below and when I call them using 
> the print function, I have something discontinous as in pink colour. 
> How do I call it so that my output should be as in blue
>>> print counter
101
>>> print miles
1000
>>> print name
joe
>>> 

This is because you are using the interactive interpreter which 
evaluates eah line as you type it. If you type your code into a file
called, say myprints.py and execute that from an OS prompt you 
will get the output you want.

Alternativbely at the >>> prompt you can either concatenate all
 the variables separated by newlines or just put all 3 commands 
on a sinlgle line separated by semicolons:

>>> print 5; print 6; print 7
5
6
7
>>> 

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list