Why does the run code button not work?

This problem didn’t appear in ’Learn to Code 1’ only ‘Learn to Code 2.’ When i hit the ‘run code’ button (at any speed), it swirls for like one second and then the ’run Code‘ button just reappears. I talked to a senior helper person at apple and we tried everything. Only when i erased my entire iPad to factory did i get code to run, but when i put everything back on the iPad it stopped runnnig. What do I do? This is frustrating!