Send string to and from raspberry pi

Does "no longer in scope" mean that data changes to whatever it was before that if statement? Because that means that data would change to 10 which would replicate the results I'm seeing. How do I make it stay in scope?