vendredi 27 mars 2015

I enter an invalid result for a while loop it works, but after a few times the while loop keeps repeating in time_taken()


client_dict = {"NeQua":"High","EmVol":"Moderate","RiVam":"High","EdLis":"Moderate"}
Intensity_sports = {"High":["swimming","aerobics"],"Moderate":["Basketball","Hiking"]}
def activity_recorder():
def clientID_choice():
global clientid,intensity
clientid = input("What client would you like to edit?:")
while clientid not in client_dict:
clientid = input("\nPlease enter the correct client\nWhat client would you like to edit?:")
intensity = client_dict[clientid]
print("\n"+clientid,"has a",intensity,"intensity\nThe reccomened sports are:")
for sports in Intensity_sports[intensity]:
print("//",sports)

**def time_taken():
global time_spent
time = [] #The variable time is equal to an empty array
for sport in Intensity_sports[intensity]:
try:
time_spent = int(input("\nPlease select the minutes spent on "+sport+":"))
while not 0 <= time_spent <= 120:
time_spent = int(input("\nPlease select the minutes spent on "+sport+" between 0 and 120:"))
except:
print("Please enter a number\nYou will be asked to re enter all your times")
time_taken()
time.append(time_spent)
total_time = 0
for time_spent in time:
total_time += time_spent
print("\n"+clientid+"'s total time spent is",total_time,"minutes")**

def again():
anotherRecord = input("\nDo you wis to enter another record? Type yes or y or no or n:")
while anotherRecord.lower() != "yes" and anotherRecord.lower() != "y" and anotherRecord.lower() != "no" and anotherRecord.lower() != "n":
anotherRecord = input("Please answer again. Yes or No?")
if anotherRecord.lower() == "yes" or anotherRecord.lower() == "y":
print("You will now enter a new client record")
activity_recorder()
else:
print("Thank you")
clientID_choice()
time_taken()
again()
activity_recorder()


Can you test it to check for any errors and help me


Aucun commentaire:

Enregistrer un commentaire