Change colour of text depending on 'if' statement

613 Views Asked by At

this is my firdt post and i need some hepl. I have started learning pyhon and have got to the point where i am ready to make my own program.

I am writing a program that is a 'stat' checker for the MMO 'Realm of the Mad God' and want to be able to change the colour of the text depending on whether the stat is < or > 0.

I have looked on this forum and the answers are either too complicated for my non-programers mind or not relevant to what i need.

essentially, i would like the extract of code below to print in diffreent colours depending on what 'if' statement the computer runs.

if hpc < 0:
    print ('    HP is above average by ' + hpc)
else:
    if hpc == 0:
        print ('    HP is average')

If anybody can help me with this and attempt to explain it in 'simple' language, i would be much obliged,

Thanks in advance!

1

There are 1 best solutions below

1
On

You need to add a module to python to accomplish this task in Windows. The colorama module can do this. https://pypi.python.org/pypi/colorama Alternatively, you can try using the win32api for python (it will work on 64 bit Windows I think) http://sourceforge.net/projects/pywin32/