[Tutor] print output
Dave Angel
davea at ieee.org
Thu Apr 16 20:26:57 CEST 2009
mbikinyi brat <mbikinyi_brat at yahoo.com> wrote:
> Dear ALL,
> 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
>
>>>> counter=101
>>>> miles=1000
>>>> name="joe"
>>>>
>
>
>>>> print counter
>>>>
> 101
>
>>>> print miles
>>>>
> 1000
>
>>>> print name
>>>>
> joe
>
> What I want:(Output)
>
> 101
> 1000
> joe
>
> Regards,
> Henry
>
>
>
I assume you're just asking all the output to come out at the same
time. Two ways to do that:
1) put multiple print statements (not print functions, as you're not
using Python 3.0) on the line, like
print counter; print miles; print name
2) Use newlines in a single print statement, to get them onto separate
lines.
print counter, "\n", miles, "\n", name
3) Write the whole thing in a definition, and call it.
def myfun():
>>> counter=101
>>> miles=1000
>>> name="joe"
>>> print counter
>>> print miles
>>> print name
>>>
myfun()
(I can't seem to get those funny vertical bars to edit right, so this
may not be formatted quite right.)
More information about the Tutor
mailing list