Hi guys, I’m new to Python and I’m having trouble printing in random colors.
A few questions:
I know you can use code like this:
print("Uh, oh, you've been given a", "\33[31m", "warning", "\033[0m", "for being a bad, bad, person.")
In that case above the word warning would be in red, and this requires no other “imports” at the beginning.
Two questions:
How do you randomize a color in that statement? Can you put a RGB value somehow in that section "\33[VariableName m", (?)
and have that variableName between 31-37.
In the tutorials, the speakers shows a question prompt in 1 color, and then the input in another. I understand the color function in (1) above is only for “print” rather than “input”. Can you do it for input also?
Basically I’m just looking for a better learning mechanism to understanding printing, inputs and randomizations with colors and everything I’m finding online is pretty confusing, involves library imports & complexity, and it’s just not simple.
The \033 is the escape code. the [38; makes it foreground, but you can use [48; for background instead. The R is the red component of your RGB, the G is your green component, and the B is the blue component.