PRINTING TEXT WITHOUT NEWLINE CHARACTERS
If you need to suppress white space and a newline between objects output with multiple print statements, you can use concatenation or the write() function.
The first technique is to concatenate the string representations of each object using the str() function prior to printing the result. For example, run the following statement in Python:
x = str(9)+str(0xff)+str(-3.1)
print('x: ',x)
The output is shown here:
x: 9255-3.1
The preceding line contains the concatenation of the numbers 9 and 255 (which is the decimal value of the hexadecimal number 0xff) and -3.1.
Incidentally, you can use the str() function with modules and user-defined classes. An example involving the Python built-in module sys is here:
>>> import sys >>> print(str(sys)) <module 'sys' (built-in)>
The following code snippet illustrates how to use the write() function to display a string:
import sys write = sys.stdout.write write(&apos...