I’m trying to change individual existing lines inside an existing tuple. Example:
JavaScript
x
12
12
1
for row in cursor:
2
print(f'''
3
4
ID: .. {row[0]}
5
Name: {row[1]}
6
Age: . {row[2]}
7
Condition: . {row[3]}
8
Medicine: .. {row[4]}
9
Temperament: .. {row[5]}
10
Adoptable: . {row[6]}
11
''')
12
I want ID to be one color, Name, Age, Condition, Medicine, Temperament, and Adoptable to be a different color.
I can’t figure out how to enter the escape codes for color inside the existing tuple. Help!
Advertisement
Answer
You need to prepend Fore.<COLOR>
and preferably append Style.RESET_ALL
to every element you want to style.
JavaScript
1
8
1
from colorama import Fore, Style
2
3
row = ('a', 'b')
4
print(f'''
5
ID: .. {Fore.YELLOW + row[0] + Style.RESET_ALL}
6
Name: {Fore.BLUE + row[1] + Style.RESET_ALL}
7
''')
8