Here is an illustration of avoiding the automatic newline during printing. Notice how each print command ending with a comma effectively builds onto what has previously been printed, but without a newline (unless a newline is part of the data to be printed, as shown here).
print "and the", |
print 3*"--\n\t***", |
print "let them go" |
If Python2 is the working environment, but you would like to use the Python3 style of printing (where print is a function rather than a command), there is a way to do this.
1 | >>> from __future__ import print_function
|
This strange-looking statement will cause any subsequent
print
in the session to behave as a
Python3 print. For example, "print 5" is considered an
error, because the syntax is changed to conform to
Python3's rules. But "print(5)" works.