For example, and for your own sake please do not copy this in its entirety, here is the code that I made to solve the very same problem. Run it, read through it. I'll look into the code you've provided, however like I mentioned earlier the format is a bit difficult for me to follow but I'll do my best to help debug it (this will take me some extra time, I'll get back to you on it). If you do decide to follow the model I've given to you, I suggest re-writing it in your own style, because I reiterate, copy-and-pasting would do you no good. With that being said, are there any stipulations that were given by your instructor that I should know about? For instance, things you can and cannot do? Minumum requirements etcetera?
Prrz
# ! Python3 def get_pints(): pints_collected = 0 pints_data = [] counter = 0 done = False while counter <= 6 and done == False: # counter <= #, # + 1 = number of inputs accepted before calcs try: pints = int(input("Enter pints collected: ")) # Accept user input if pints < 0: # Check if negative print("You've entered a Negative number.") else: # If not, add the number to the total and the list pints_collected += pints # Adds input to total pints_data.append(pints) # Appends input into a list counter += 1 # Adds 1 to counter print(pints_data) # Only for testing purposes, delete later print(pints_collected) # Only for testing purposes, delete later except ValueError: # If not a number print("That is not a valid entry, try again please.") else: # 7 is number of inputs taken, change if (counter <= #) is changed average = round(pints_collected / 7) maximum = max(pints_data) minimum = min(pints_data) print("The average number of pints donated is: ",average) print("The highest pints donated is ",maximum) print("The lowest pints donated is ",minimum) retry = input("End the program? (Yes or No): ").upper() # Eliminates case errors in input if retry == "NO": pints_collected = 0 # Reset total pints_data = [] # Reset list counter = 0 # Reset counter return get_pints() # Return original function else: print("Goodbye!") done = True get_pints() # Start program by calling get_pints functionRegards,
Prrz