Codeair Mission 6 Objective 5 Question

Tried using the exact sequence at the end of this mission but it didn’t check if off as Complete.
Made sure that the sequence was right with the correct color sequence.

Thanks

Hey Scott, could you post your code?
Also, which of the goals are not turning green, is the just the last one?

Thanks!

from codeair import *
from time import sleep

def select_index(num_items):

num_items = min(num_items, 255)
choice = 1
leds.set_status(50)
leds.set_mask(choice, 50)

while True:
    if buttons.was_pressed(BTN_1):
        choice = choice + 1

        if choice > num_items:
            choice = 1
        speaker.beep(880, 50)
        leds.set_mask(choice, 50)
        sleep(0.15)
        buttons.was_pressed()

    elif buttons.was_pressed(BTN_0):
        speaker.beep(1000, 50)
        speaker.beep(1200, 20)
        break

for i in range(3):
    leds.set_mask(choice, 70)
    sleep(0.3)
    leds.set_mask(0, 0)
    sleep(0.2)

leds.set_status(0)
buttons.was_pressed()
return choice

Test program for selectable ops

if name == ‘main’:
print(“Loaded module for testing.”)

color_list = [BLUE, WHITE, GREEN, RED, MAGENTA]

while True:

    i = select_index(len(color_list))

    color = color_list[i - 1]

    pixels.fill(color)

    freq = 400 + i * 100
    speaker.beep(freq, 1000)

Made sure that BLUE, GREEN, MAGENTA, RED, WHITE are lit in that exact order and still didn’t complete the task

Thanks for sending your code!

Unfortunately, the issue is from the omission of the print statement print("selected index=", i).

Turn the while loop from this:

while True:
    i = select_index(len(color_list))

    color = color_list[i - 1]

    pixels.fill(color)

    freq = 400 + i * 100
    speaker.beep(freq, 1000)

To this:

while True:
    i = select_index(len(color_list))
    print("selected index=", i)

    color = color_list[i - 1]

    pixels.fill(color)

    freq = 400 + i * 100
    speaker.beep(freq, 1000)

We’ve got limited ways to check if the submitted code is correct. In this objective we’re using the console logs to check that the buttons were pressed in the correct order, so the print statement is necessary.

Apologies for the inconvenience, let me know if this doesn’t resolve the problem.