In python 3
for elem in [10, 20, 25, 27, 28.5]:
#instered of using this print(elem),
#use
print(elem,end=' ') #space in inverted comma.
thanks
On Friday, 19 December 2014 16:55:43 UTC+5:30, Lei wrote:
>
> 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!
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.