Lei
2014-12-19 11:25:43 UTC
Hi experts,
I am using python 3.
I wrote in IPython console in Spyder
for elem in [10, 20, 25, 27, 28.5]:
print(elem),
But the results are
10
20
25
27
28.5
As I learned, the comma in the syntax "print(elem)," will prevent the use
of newline character. Why does it not work here?
How can I make the results in one line? Like
10 20 25 27 28.5
I know I can use
print([elem for elem in [10, 20, 25, 27, 28.5]])
and I get
[10, 20, 25, 27, 28.5]
But this is not something I want. What I want is, with the first codes, why
the results are in vertical line, even with the comma?
Thanks!
I am using python 3.
I wrote in IPython console in Spyder
for elem in [10, 20, 25, 27, 28.5]:
print(elem),
But the results are
10
20
25
27
28.5
As I learned, the comma in the syntax "print(elem)," will prevent the use
of newline character. Why does it not work here?
How can I make the results in one line? Like
10 20 25 27 28.5
I know I can use
print([elem for elem in [10, 20, 25, 27, 28.5]])
and I get
[10, 20, 25, 27, 28.5]
But this is not something I want. What I want is, with the first codes, why
the results are in vertical line, even with the comma?
Thanks!
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.