Answer to Question #247112 in Computer Networks for Licinda Wait

Question #247112
# Format the background colour of previousPriceLabel to be blue. Refer to the following site:
# https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python
# Follow the above site to add special text characters to the label, which the console will interpret
# as background colour settings. If the above site's code does not work for your console (I am using
# Visual Studio Code), research a different way for setting the background colour
1
Expert's answer
2021-10-05T23:13:28-0400
def printBackgroundColor():
    
    for colorStrip in range(8):
        for middleRange in range(30,38):
            s1 = ''
            for backGround in range(40,48):
                format = ';'.join([str(colorStrip), str(middleRange), str(backGround)])
                s1 += '\x1b[%sm %s \x1b[0m' % (format, format)
            print(s1)
        print('\n')


printBackgroundColor()


Output:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS