How do I execute code sequentially in pyscript py-repl?

50 views Asked by At
move()
if(character_data[0]['x']>=1):
    say("Yes")
else:
    say("NO")

I'm currently working with pyscript.

When you put the code above into a code block (py-repl) and run it, (The character's position was set to x+= 1 using the move function.) In this case, the x-coordinate should be 1 and say("YES") should be executed.

All code is executed at once and say("NO") is output.

Is there any way to solve these problems?

For example, do you run the code line by line in Py-repl?

1

There are 1 answers

0
Jeff Glass On

I'm not sure I'm understanding your question - here's a simple implementation of what it sounds like the rest of your code is doing:

character_data = [{'x': 0, 'y': 0}]

def move():
  character_data[0]['x'] += 1  

move()

if(character_data[0]['x']>=1):
    print("Yes")
else:
    print("NO")

print(f"{character_data[0]['x']=}")

This prints Yes, character_data[0]['x']=1. So the issue may be in your data handling, or the say() function or similar. Can you expand on your example, or share more code?