Feb-11-2018, 02:59 AM
I am having trouble figuring out why my totalList is only printing the last total that is appended to the list rather than everyone that is apart of the loop?
value = int(input("Enter a numeric value: ")) if value % 2 == 0: even += 1 elif value % 2 == 1: odd += 1 cumTotal += value print("Your current total is: %d" % cumTotal) # Here is where the smallest and largest values start as # the initial value that is entered smallest = value largest = value # Using user input allows no mix ups with other values interfering # with the previous variable userInput = input("Enter a value or 'Q' to quit: ") previous = userInput # Here is where the while loop enters while userInput != "Q": totalList = [] if previous == value: duplicates = str(previous) + " " + duplicates previous = value value = int(userInput) cumTotal += value print("Your current total is: %d" % cumTotal) if value > largest: largest = value # This elif statement allows the possibility of the value # to actually now be the smallest number entered elif value < smallest: smallest = value if value % 2 == 0: even += 1 elif value % 2 == 1: odd += 1 totalList.append(cumTotal) userInput = input("Enter a value or Q to quit: ")