Here is a sample of the textfile I use:
NaQua,High
ImKol,Moderate
YoTri,Moderate
RoDen,High
NaThe,Moderate
ReWes,Moderate
BrFre,High
KaDat,High
ViRil,High
TrGeo,High
For some reason, the program will only work with the last client id on the list. It prints the intensity level but then stops right there as if that's the end of the program.
pie = 'pie'
while pie == 'pie':
f=open('clientIntensity.txt')
lines=f.readlines()
print ((lines[0])[:5])
print ((lines[1])[:5])
print ((lines[2])[:5])
print ((lines[3])[:5])
print ((lines[4])[:5])
print ((lines[5])[:5])
print ((lines[6])[:5])
print ((lines[7])[:5])
print ((lines[8])[:5])
print ((lines[9])[:5])
clientid = input("Please select and input the ID of the client that you would like to record exercise times for. (case sensitive)")
with open('clientIntensity.txt') as f:
for line in f:
if clientid in line:
clientintensity = line[6:]
print ("The client you have selected has an exercise intensity of",clientintensity)
if clientintensity == 'High':
print ("The exercises for this intensitity level are, Running Swimming Aerobics Football Tennis.")
while True:
try:
Running = input("Please enter the amount of time that the client spent running.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Swimming = input("Please enter the amount of time that the client spent swimming.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Aerobics = input("Please enter the amount of time that the client spent doing aerobics.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Football = input("Please enter the amount of time that the client spent playing football.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Tennis = input("Please enter the amount of time that the client spent playing tennis.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
totaltime = ((Running)+(Swimming)+(Aerobics)+(Football)+(Tennis))
print (clientid,"spent a total time of",totaltime,"exercising this week.")
elif clientintensity == 'Moderate':
print ("The exercises for this intensitity level are, Walking Hiking Cleaning Skateboarding Basketball")
while True:
try:
Walking = input("Please enter the amount of time that the client spent walking.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Hiking = input("Please enter the amount of time that the client spent hiking.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Cleaning = input("Please enter the amount of time that the client spent cleaning.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Skateboarding = input("Please enter the amount of time that the client spent skateboarding.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
while True:
try:
Basketball = input("Please enter the amount of time that the client spent playing basketball.(0-120 minutes)")
except ValueError:
print ("Please enter a valid time.")
continue
else:
break
totaltime = ((Walking)+(Hiking)+(Cleaning)+(Skateboarding)+(Basketball))
print (clientid,"spent a total time of",totaltime,"exercising this week.")
again = input("Would you like to input times for another client?(Y/N")
if again == 'N':
pie = 'superpie'