0
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 Answer 1

0

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.