Nov-27-2018, 07:13 PM
This is not homework. I was practicing python lists and wanted to total and average the simple list that I wrote. The code runs with no errors but it does not total or average at the end of the program. Should I have used a different type of loop when creating the list, like While instead of For? I like using the for statement as opposed to While when creating the list because it seems to be less code to write. Here's what I have.
#Create List with user input accountBalance = [0] * 5 for bal in accountBalance: bal = float(input("Enter")) #Procces list for total and average total = 0 for acct in accountBalance: total = total + acct average = total / len(accountBalance) print("Total: ", total) print("Average: ", round(average, 2))