In this article, we will learn how we can change the format of output display on the console in the python print command. You can use the below code snippet to achieve this. We are going to use the colour class and define the colour of each colour and in the print statement, we are going to access the colour of that class.
class color: PURPLE = '\033[95m' CYAN = '\033[96m' DARKCYAN = '\033[36m' BLUE = '\033[94m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' BOLD = '\033[1m' UNDERLINE = '\033[4m' END = '\033[0m' print(color.BOLD + 'Hello World !' + color.END)
Let us know if you face any issues in the implementation of the above code.
Leave a Reply