Print() in Python

A guide to printing and formatting your scripts output.

Keno Leon
8 min readFeb 8, 2020

--

Why read this ?While a basic print statement can serve you well, you will be printing a lot while debugging and getting results from your scripts, as such, it is a good investment, additionally it will help you read others code and look at some more advanced use cases.print('Win Win')

Basics

We all start here:

print(‘Hello World’)# OUTPUT:Hello World

If you want to separate the output into different lines, just use \n

print('Hello \nWorld')# OUTPUT:Hello
World

Numbers require you to cast them as strings :

print ('this is line: ' + str(1))
print ('this is line: ' + str(2))
# OUTPUT:This is line: 1
This is line: 2

And of course you can wrap everything in a function and print the output:

def gDay():    
return ('Good Day Sir !')
print(gDay())# OUTPUT:Good Day Sir

--

--