I'm now running an error (first off I already know that using exec
isn't the best option but I'd rather not get into that right now) about a variable being undefined when referencing it. Which I find very strange considering it was working perfectly fine when I was using exec(f'oneMileMark.append(entry{i}.get())')
(it was already a float at this point) before I added the ability to use the standard time format (1:36).
for i in range(numOfRunners):
if i%4 == 0: # used to distinguish between a runner's name and different times
exec(f'time = entry{i}.get()') # gets the value of entry{i} and saves it as time
minutes,seconds=time.split(':') # splits time into mins and secs
newTime=float(minutes) + float(seconds)/60 # combines the minutes and hours into one bariable
oneMileMark.append(newTime) # adds newTime to a list
Which gives the error:
Traceback (most recent call last):
File "/Users/Me/Desktop/Computer Programming/Python 3.x/Assignments/Programming 2/8/9_15 Computing 5k Mile Splits/main.py", line 91, in <module>
app = Application(root)
File "/Users/Me/Desktop/Computer Programming/Python 3.x/Assignments/Programming 2/8/9_15 Computing 5k Mile Splits/main.py", line 12, in __init__
self.get_runner_data()
File "/Users/Me/Desktop/Computer Programming/Python 3.x/Assignments/Programming 2/8/9_15 Computing 5k Mile Splits/main.py", line 53, in get_runner_data
hours,minutes=time.split(':')
NameError: name 'time' is not defined