0

I'm trying to turn certain letters in a word a different colour, and the word as a whole.

I've tried using termcolor and ANSI escape codes and they don't work.

I'm using IDLE as my IDE and Python 3 so this could be the reason? Does anyone have any solutions that work for these conditions?

Rey
  • 1
  • ANSI escape sequences only work if the code is run in a terminal, like CMD on Windows. IDLE is not a terminal, which is why they don't work. – MattDMo Jul 26 '22 at 20:13
  • Looks like there is a few great answers in this thread:: https://stackoverflow.com/questions/287871/how-do-i-print-colored-text-to-the-terminal – swingline_in_jello Jul 26 '22 at 20:19

1 Answers1

2

I'm using IDLE as my IDE and Python 3 so this could be the reason? Does anyone have any solutions that work for these conditions?

Yes, this is the reason. ANSI escape sequences only work on terminals, eg: CMD, Powershell, etc. Run your code using python3 file.py in the terminal and ANSI should work properly.

Naitik Mundra
  • 418
  • 3
  • 14