# Using normal python in makecode but it's not working

**URL:** https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746
**Category:** TEALS Intro CS
**Created:** [January 8, 2024, 5:54pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746 "2024-01-08T17:54:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![john.holland.teals](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john.holland.teals](https://forum.makecode.com/u/john.holland.teals)
#### Post date: [January 8, 2024, 5:54pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/1 "2024-01-08T17:54:22Z")

</div>

Hello, I am volunteering to help teach Intro to CS with Makecode. We are in unit 3 currently (of semester 1). I am looking ahead at the prospect of switching to python or typescript which I think happens in a later unit or even semester 2. I am testing makecode with some simple python code but finding it doesn’t seem to handle it well. The error it reports doesn’t make sense and it is referencing a javascript/typescript function. It looks to me like typescript may be the language it actually runs in? The code is pretty simple but doesn’t work. It works fine in VSCode or a typescript online repl if I change the game.splash() to print(). This is giving me doubts about using the makecode curriculum after it switches to python from blocks. Does anyone have any comments?

```auto
def naive(all_the_numbers, max_num):
    for outer in range(max_num):
        for inner in range(2, outer):
            if outer % inner == 0:
                all_the_numbers[outer] = False
                break

MAX_NUM = 15
all_the_numbers = [True]
for push_index in range(0, MAX_NUM):
    all_the_numbers.append(True)
naive(all_the_numbers, MAX_NUM)
     
for print_index in range(MAX_NUM - 1):
    if all_the_numbers[print_index] == True:
        game.splash(print_index)

```

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [January 8, 2024, 7:58pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/2 "2024-01-08T19:58:16Z")

</div>

Would you mind sharing the link to this project so I can take a look? It will help me understand the errors being suggested so I can get a better idea of what’s going on.

---

<div class="post-metadata">

### Author: ![john.holland.teals](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john.holland.teals](https://forum.makecode.com/u/john.holland.teals)
#### Post date: [January 8, 2024, 11:16pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/3 "2024-01-08T23:16:56Z")

</div>

> **[testpy2](https://arcade.makecode.com/S58728-10044-08431-53417)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Hi, sorry I didn’t see your email til just now.

---

<div class="post-metadata">

### Author: ![john.holland.teals](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john.holland.teals](https://forum.makecode.com/u/john.holland.teals)
#### Post date: [January 8, 2024, 11:17pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/4 "2024-01-08T23:17:01Z")

</div>

(it’s an example of a naive approach to finding prime numbers). I just grabbed it as some sample python to try in MakeCode.

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [January 10, 2024, 10:51pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/5 "2024-01-10T22:51:28Z")

</div>

This is a bug in MakeCode, I’ve filed an issue for it here: [https://github.com/microsoft/pxt-arcade/issues/6320](https://github.com/microsoft/pxt-arcade/issues/6320)

As a workaround, you can fix it by adding a type hint to the `all_the_numbers` parameter like so:

```python
def naive(all_the_numbers: List[bool], max_num):
    for outer in range(max_num):
        for inner in range(2, outer):
            if outer % inner == 0:
                all_the_numbers[outer] = False
                break

MAX_NUM = 15
all_the_numbers = [True]
for push_index in range(0, MAX_NUM):
    all_the_numbers.append(True)
naive(all_the_numbers, MAX_NUM)
     
for print_index in range(MAX_NUM - 1):
    if all_the_numbers[print_index] == True:
        game.splash(print_index)

```

note the `: List[bool]` after the `all_the_numbers` parameter

---

<div class="post-metadata">

### Author: ![john.holland.teals](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john.holland.teals](https://forum.makecode.com/u/john.holland.teals)
#### Post date: [January 11, 2024, 12:02am UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/6 "2024-01-11T00:02:18Z")

</div>

Sorry, but playing around a little more I found something else. This line of code is reported as invalid, but it is also normal python:  
all\_the\_numbers = [True] \* MAX\_NUM

(this would create an array of True booleans of length MAX\_NUM)

MakeCode responds with an error message:  
Line 9: types not compatible: boolean and number

---

<div class="post-metadata">

### Author: ![john.holland.teals](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@john.holland.teals](https://forum.makecode.com/u/john.holland.teals)
#### Post date: [January 11, 2024, 12:02am UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/7 "2024-01-11T00:02:31Z")

</div>

I see that that fixes it. It seems like the Python in MakeCode is not vanilla Python, as I think is indicated in the docs. Is there documentation for the differences?

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [January 11, 2024, 12:04am UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/8 "2024-01-11T00:04:31Z")

</div>

> **[Python in MakeCode](https://makecode.com/python)**
>
> Our Python support is called MakeCode Python. As with TypeScript, the Python implementation is a subset of the full Python languange.

but i’m not sure those docs are complete. makecode python is referred to as “static python”, and it does not support everything in normal python

---

<div class="post-metadata">

### Author: ![IanOstrom](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ianostrom/32/8192_2.png) [@IanOstrom](https://forum.makecode.com/u/IanOstrom)
#### Post date: [March 28, 2025, 5:09pm UTC](https://forum.makecode.com/t/using-normal-python-in-makecode-but-its-not-working/25746/9 "2025-03-28T17:09:11Z")

</div>

The MakeCode Python documentation is limited. This cheat sheet for type hints in python has been helpful.

[# Type hints cheat sheet](https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html)
