how to code python 3 function on raspberry pi?

Viewed 17

Code a Python 3 Function to display a message on the Sense Hat board with the following specifications •The program will prompt the user to choose the colour of the message.

from sense_hat import SenseHat
sense = SenseHat()

def get_color(color):
  count = 1
  while True:
    color_str = input("Enter the value of " + color + \
    " color for message (0 to 255): ")
    color_int = int(color_str)
    
    if color_int not in range (0,256):
      print("Wrong")
      count = count +1 
      
        if count > 3:
          color_int = 0
    
  else:
    return
    
r = get_color("red")
g = get_color("green")
b = get_color("blue")
msg_color = (r,g,b)

print(msg_color)
sense.show_message("helloooo", text_colour = msg_color)
0 Answers
Related