# Help with Python code for CodeX

**URL:** <https://community.firialabs.com/t/help-with-python-code-for-codex/353>\
**Category:** Support\
**Created:** [October 2, 2026, 3:11pm UTC](https://community.firialabs.com/t/help-with-python-code-for-codex/353 "2026-10-02T15:11:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dewing](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.firialabs.com/dewing/32/14_2.png) [@dewing](https://community.firialabs.com/u/dewing)\
**Post date:** [October 2, 2026, 3:11pm UTC](https://community.firialabs.com/t/help-with-python-code-for-codex/353/1 "2026-10-02T15:11:27Z")

</div>

Question from a student - posting here to see if maybe @Sam could help?

The student says the sound is not working on his remix ☹ See code below!

```auto
from codex import*
from time import sleep

delay = 1

color = RED
pixels.set(0, color)
sleep(delay)

color = YELLOW
pixels.set(1, color)
sleep(delay)

color = GREEN
pixels.set(2, color)
sleep(delay)

color = BLUE
pixels.set(3, color)
sleep(delay)

while True:
if buttons.is_pressed(BTN_A):
    audio.mp3("sounds/africa")
sleep(0.05)

```

---

<div class="post-metadata">

**Author:** ![Sam](https://yyz2.discourse-cdn.com/flex008/user_avatar/community.firialabs.com/sam/32/210_2.png) [@Sam](https://community.firialabs.com/u/Sam)\
**Post date:** [October 2, 2026, 3:18pm UTC](https://community.firialabs.com/t/help-with-python-code-for-codex/353/2 "2026-10-02T15:18:21Z")

</div>

The pixel sequence looks fine — the sound never gets a chance to run because of indentation.

In the code as posted, Python expects an indented block after `while True:`, but the `if` is sitting at the same indent level. That usually shows up as an `IndentationError` in the CodeSpace debug console, and the button/MP3 loop never starts.

Try this for the last part:

```python
while True:
    if buttons.is_pressed(BTN_A):
        audio.mp3("sounds/africa")
    sleep(0.05)

```

A couple of extra notes:

- `audio.mp3("sounds/africa")` is the right path for the built-in song. The `.mp3` extension is optional — see the [CodeX audio docs](https://docs.firialabs.com/codex/codec.html).
- `audio.mp3()` plays the whole file before the loop continues, so a press on **A** should still work once the indent is fixed.
- Worth adding a space in `from codex import *` for readability (Python will accept it either way).

If the lights work but there’s still no sound after that change, check the debug console for a file-not-found error, and that volume isn’t turned down / the speaker isn’t muted by headphones.

@Kathy @dewing
