Code: Select all
from sense_hat import SenseHat
from time import sleep
from random import randint
sense = SenseHat()
r = (255,0,0)
b = (0 ,0, 255)
g = (0, 255, 0)
while True:
red = int(input("Please enter the value of the red color for message"))
if 0 < red < 255:
print("That is a correct value")
r = (red,0,0)
elif red > 255:
print("That is not a valid number, Try again...")
continue
green = int(input("Please enter the value of the blue color for message"))
if 0 < green < 255:
print("That is a correct value")
r = (red,green,0)
elif green > 255:
print("That is not a valid number, Try again...")
continue
blue = int(input("Please enter the value of the green color for message"))
if 0 < blue < 255:
print("That is a correct value")
r = (red,green,blue)
elif blue > 255:
print("That is not a valid number, Try again...")
continue
try:
scroll_speed = float(input("Please enter scroll speed")) #enter an int or float to break program
break
except ValueError:
print("Oops! That was no valid number. Try again...")
sense.show_message("Studying",text_colour = r, back_colour = b,scroll_speed = 0.05)
sense.clear()How would you resolve this in your design to let the user try again and again until the user enter correct input?