Set example_list = list()
, then do a for
loop where each time you ask for input and add the value to the list via example_list.append(input_response)
.
Extract the values back out using the same for
loop to cycle through the list.
example_list = list()
total = 0
max_value = 0
for stored_number in example_list:
# Ask for input and store in input_response variable
example_list.append(input_response)
# Here is where you could add the values to a counter variable,
# as well as check whether they are the maximum
total += stored_number
if stored_number > max:
max_value = stored_number
# Display results
For what you want, you could also just use the built-in functions max and sum:
max_value = max(example_list)
total = sum(example_list)
solved Python number processing trouble