I'm just beginning to learn Python on my own, and I'm trying to write a code that will calculate the end time of a jog.
My code so far looks as follows:
def elapsed(t): t = raw_input('Enter time (hh:mm:ss): ') th, tm, ts = t.split(':') return int(ts) + int(tm) * 60 + int(th) * 3600 def mile(m): m = raw_input('How many miles? ') return int(m) start = elapsed('start') warmup = elapsed('warmup') wmile = mile('wmile') tempo = elapsed('tempo') tmile = mile('tmile') cooloff = elapsed('cooloff') cmile = mile('cmile') hour = (start + warmup * wmile + tempo * tmile + cooloff * cmile) // 3600 minute = (start + warmup * wmile + tempo * tmile + cooloff * cmile - hour * 3600) // 60 second = (start + warmup * wmile + tempo * tmile + cooloff * cmile - hour * 3600) % 60 print('Your run ended at %02d:%02d:%02d' % (hour, minute, second)) In this code, the time prompts are all the same: "Enter time (hh:mm:ss):" I want each prompt to refer to its variable name, e.g., "Enter start time (hh:mm:ss)" or "Enter time (hh:mm:ss): (warmup)". Is there a way to do this?
Note: While this may technically be a duplicate, I have examined the similar questions, but decided that both the questions and the answers provided were on the more unspecific side, and therefore decided to ask my question anyway.
t = raw_input('Enter {} time (hh:mm:ss): '.format(t))