Skip to content
← Back to Community
How to make a Beautiful Output
Profile icon
pr0p3rno0b10

What is Beautiful Output?

hmmmm, what is beautiful output. Well, beautiful output is something that I made up. Basically, what it is making your code output look good and organized. The whole point of this tutorial is for you to learn how to make your python code output look good.

Everyone has their own opinion, therefore if you disagree thats cool, if you have any constructive feedback, thats cool too, put it in the comments.

1)

In number 1 we are introducing \n. \n is useful because you can make a new line with it. Like this:

print('\n')

That can be used in many ways. For example,

print("You say Hii") print("\n\n") print("She says hello")

2)

In number 2 we will learn about clearing the console, this is useful because we can clear any lines that we don't want.
This is my way on how you clear the console:

import os def clear(): os.system("clear")

os is a really cool module that is useful for many things. In this case we are using os for clearing. Lets put this code into an example:

hi = input("What is your name: ") clear() print(f"hi, {hi}")

3)

In number 3, we are going to learn about colors! Colors make your code come to life! There is only one problem, how do we get colors? There are many ways, but my favorite is termcolor. Here is how it works:

import termcolor termcolor.cprint("Hi", 'green') # or you could do print("hi"+termcolor.colored("my name is...", "green"))

Thank you for coming to my tutorial

Hoped you enjoyed and bye

Voters
Profile icon
JS-11ZZ-682797
Profile icon
pr0p3rno0b10
Comments
hotnewtop
Profile icon
CodeLongAndPros

Uh termcolor is bad, just use ANSI:

python("\033[31mRed\033[0m"

Profile icon
CodingCactus

hi, in your tutorial you do this

print("You say Hii") print("\n\n") print("She says hello")

But why would you do that? Surely it makes a lot more sense to do this

print("You say Hii\n\n\n\nShe says hello")