-2

My code:

print "*" 
print "*" 

Output:

*
*

But what I want is:

* *

How can I do it?

  • Possible duplicate of [Python print on same line](http://stackoverflow.com/questions/5598181/python-print-on-same-line) – cfi Oct 24 '15 at 20:40

2 Answers2

4

Put commas at the end of first print statement:

print '*',
print '*'

Output:

* *

You can do help('print').

Remi Guan
  • 21,506
  • 17
  • 64
  • 87
LetzerWille
  • 5,355
  • 4
  • 23
  • 26
0

To simply avoid adding a newline, do as @LetzerWille instructs; add a comma.

To print the same character/string multiple times on a line, do

print('* ' * 2)

See: Python display string multiple times

Community
  • 1
  • 1