''' Mission 8 Answer Bot Spicy Remix 3A Create two lists of pictures, colors and text. Use BTN_A and BTN_B to select which list to use. Use BTN_L and BTN_R to scroll, and BTN_U for random. Use BTN_D to quit. If the lists are the same lengths, you can use a single variable (constant) for the last index. If the lists are different lengths, you will need to change the value of the last index. ''' from codex import * import random from time import sleep # My list of pictures, colors and text my_list1 = [pics.TIARA, GREEN, pics.PLANE, "hello!", pics.HAPPY, BLUE, pics.TARGET, "what's up?", RED, "Ahoy", pics.HEART] # my list of JPG pics uploaded to Codex my_list2 = ["The odds are yes", "It is not in the stars", "Go for the gold!", "Today is your day", "Stay home and read", "Have an adventure", pics.HEART, pics.TIARA, pics.PLANE, pics.HAPPY] # Introduction display.print("A=List 1", scale=3) display.print("B=List 2", scale=3) display.print("L=scroll<-", scale=3) display.print("R=scroll->", scale=3) display.print("U=random", scale=3) display.print("D=quit", scale=3) # Hold the instructions until A or B is pressed # Alternatively, you can just assign values to # the_list and the_last without waiting for a button press while True: if buttons.was_pressed(BTN_A): the_list = my_list1 the_last = len(my_list1) index = 0 break if buttons.was_pressed(BTN_B): the_list = my_list2 the_last = len(my_list2) index = 0 break # Continue to show images until D is pressed while True: #display item from list item = the_list[index] if type(item) == tuple: display.fill(item) else: display.show(item) # Scroll left if buttons.was_pressed(BTN_L): index = index - 1 if index < 0: index = the_last - 1 # Scroll right if buttons.was_pressed(BTN_R): index = index + 1 if index >= the_last: index = 0 # Get random item if buttons.was_pressed(BTN_U): index = random.randrange(the_last) # Select the first list if buttons.was_pressed(BTN_A): the_list = my_list1 the_last = len(my_list1) if index >= the_last: index = the_last - 1 # Select the last list if buttons.was_pressed(BTN_B): the_list = my_list2 the_last = len(my_list2) if index >= the_last: index = the_last - 1 if buttons.was_pressed(BTN_D): break # Ending message display.clear() display.print("Thanks", scale=5)