Can someone please explain why i get this error?


I

at the top of the function you have a check where the code will only run if the parameter is 1 – this new check you’re adding (if num is 2) is contained within that first check (meaning, it only runs if the first check has passed) – meaning that num would have to be both 1 and 2 at the same time for that code to work, which isn’t possible.

In this case It looks like you probably just meant them to be separate checks – in which case you should back out the indentation - instead of this:

image

you want this:
image
(or this
image
which would help enforce that they’re separate cases even more)

For future questions, it’s usually easiest if you create a share link and share the project or a section showing the error if possible so we can help debug / provide the answer in context~

1 Like

is robots talking a sprite?

If i’m not mistaken, this behaviour is inherited from TS. It’s not something that happens in Python, but it’s an evaluation that fails since the code has to be transpiled to TS first

Soooo, i just noticed the second ‘if’ statement is nested and thats what caused the error.

1 Like

Yeah, what Joey said. Since the code’s already checking that num == 1, nesting the condition num == 2 within it will create a case that will never be reached. Standard Python would support something like this, but since TS doesn’t support that behavior, an error is thrown.

Like I mentioned already,