0
print("Player 1 is up")`
print("Player 2 is up")`

I would like to be able to print the text in the console as a different color for each player, I've tried a couple of the imports, but it doesn't work. Any help would be gratefully received.

As shown below my attempt at trying one of the suggestions on the "How to print colored text in python. I have tried a lot of ways, but they all print the ANSI escape sequence.

image attempt

ZF007
  • 3,708
  • 8
  • 29
  • 48
  • I voted to reopen your question under the premise that you describe [which approaches in the suggested duplicate question](https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-python) you have tried and what the outcomes were. A vague "I tried so many things and nothing works" will not be enough. – Mr. T Oct 28 '20 at 23:44

1 Answers1

0

You have to add the code for the color you want displayed. For instance: Let's say i want to print out the text "This is not white" with a pink outline. Then by using the print-function, i first add the color for pink and then the text i want displayed within the print-function. The code for pink is: \x1b[1;45m So adding the two together:

print('\x1b[1;45m' + 'This is not white.')

It is kind of like adding to string-values together in a print-statement.

The output will be "This is not white" in a pink outline.

Slangegift
  • 30
  • 5