a, b = "\033[0;37m hi", "\033[0;36m hi"
if a == b:
print('hi')
else:
print('bye')
Can you ignore the coloring in the if statement to make it print hi?
a, b = "\033[0;37m hi", "\033[0;36m hi"
if a == b:
print('hi')
else:
print('bye')
Can you ignore the coloring in the if statement to make it print hi?
You can do that easily by splitting these two strings for example:
a, b = "\033[0;37m hi", "\033[0;36m hi"
if a.split(' ')[1] == b.split(' ')[1]:
print('hi')
else:
print('bye')
I recommend this way I find it more elegant and easy
#add this class to your file
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
#you can add more colors here
How to use
a = "Hi"
print(f"{bcolors.OKGREEN}", a , f"{bcolors.ENDC}")
Now you can compare two strings normally