Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How do you print multiple things on one statement in Python?

python 3:

print('Python', 3, 'Rocks')
>>> Python 3 Rocks

with sep:
print('Python', 3, 'Rocks', sep='|')
>>> Python|3|Rocks

(sep=' ' is added by default, so to print space between values, 
sep is not necessary)

with end:
by default, end="
" is appended, so to print a new line after, end is not
necessary. However you can replace 
 with something else.

print('Python', 3, 'Rocks', end='*')
print('I love Python')
>>> Python 3 Rocks*I love Python


python 2:
print 'Python', 2, 'Rocks'
>>> Python 2 Rocks

with sep:
from __future__ import print_function
print("Python","Rocks", sep="|")
>>> Python|3|Rocks

similar to end:
  just add a comma after the first print statement
print 'Python', 2, 'Rocks', '*',
print 'I love Python'
>>> Python 3 Rocks*I love Python
Comment

PREVIOUS NEXT
Code Example
Python :: how to remove all zeros from a list in python 
Python :: python fizzbuzz 
Python :: resample python numpy 
Python :: pyperclip copy paste 
Python :: binomial coefficient python 
Python :: pandas plot histogram 
Python :: python clear screen windows and linux 
Python :: explode dictionary pandas 
Python :: convert_text_to_hexadecimal_viva.py in python 
Python :: how to define dtype of each column before actually reading csv file 
Python :: django is null 
Python :: blender python save file 
Python :: python read column data from text file 
Python :: limpiar consola en python 
Python :: python list remove spaces 
Python :: connect flask with postgresql 
Python :: How to Add R to Jupyter Notebook 
Python :: Tkinter canvas draggable 
Python :: comment concatener deux listes python 
Python :: boxplot for all columns in python 
Python :: remove outliers in dataframe 
Python :: how to create a python venv 
Python :: python script to read all file names in a folder 
Python :: python inline conditional 
Python :: how to run for loop in python 
Python :: latency discord.py 
Python :: spread operator python 
Python :: how to playsound in python 
Python :: tkinter starter code 
Python :: python emojis 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =