Advertisement
plirof2

PYTHON print in color

Jun 10th, 2022 (edited)
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. #https://stackoverflow.com/questions/39473297/how-do-i-print-colored-output-with-python-3
  2. import random
  3.  
  4. class color:
  5.    BLUE = '\033[1;34;48m'
  6.    RED = '\033[1;31;48m'
  7.    PURPLE = '\033[1;35;48m'
  8.    GREEN = '\033[1;32;48m'
  9.    CYAN = '\033[1;36;48m'
  10.    YELLOW = '\033[1;33;48m'
  11.    WHITE= '\033[1;37;0m'
  12.    BLACK = '\033[1;30;48m'
  13.    END = '\033[1;37;0m'
  14.  
  15.    BOLD = '\033[1;37;48m'
  16.  
  17.    UNDERLINE = '\033[4;37;48m'
  18.  
  19.  
  20. my_color = [color.BLACK,color.BLUE, color.RED ,color.PURPLE, color.GREEN, color.CYAN, color.YELLOW, color.WHITE]
  21. INK=[color.BLACK,color.BLUE, color.RED ,color.PURPLE, color.GREEN, color.CYAN, color.YELLOW, color.WHITE]
  22. PAPER=INK.copy()
  23. #print(color.BLUE + "hello friends" + color.END)
  24. #https://gist.github.com/RabaDabaDoba/145049536f815903c79944599c6f952a
  25. def rnd(myarray) : return random.choice(myarray)
  26.  
  27. times=10
  28.  
  29.  
  30. a = input("Enter your text to be colourful: ")
  31. new_text =""
  32. for x in a:
  33.     new_text += x + rnd(INK)
  34.  
  35. #print (new_text + color.END)
  36. print (new_text + INK[7])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement