Using exec to define and get the value from variables raises NameError
问题 Right now I'm working on a project that will ask for a runner's name, 1 mile, 2 mile, and 5 miles times and generate data based off that. The requirement is to have enough entries for 7 runners but I thought I'd add the ability to add any number of runners by using exec() . However, when trying to read data from the variables defined within them, I get a NameError: name 'entry2' is not defined but not for entry0 and entry1 , so I was wondering if anyone could help me out on these. In case it