-1
i = 0
integers = []
total = 0
while i < 10:
num = input('Enter an integer: ')
    try:
        integers.append(int(num))
        i = i + 1
    except:
        print('Bad input')
for i in integers:
    total = total + 1
average = total / 10
print('this is the list of integers you entered: ',(integers))
print('The lowest number is: ',min(integers))
print('The highest number is: ',max(integers))
print('This is the average of all integers: ',(average))
sorted_list = sorted(integers)
print('The integers list sorted in ascending sequence: ',(sorted_list))
sorted_list.reverse()
print('The  integers list sorted in descending sequence: ',(sorted_list))

currently the total is equal to however many integers i enter i understand its from total = total + 1 how would i go about getting the total to be the total of all integers entered?

llama
  • 35
  • 4

2 Answers2

2

Just do

total = total + i

and check the indentation in the line

num = input('Enter an integer: ')

it should be one level indside

pramesh
  • 1,914
  • 1
  • 19
  • 30
  • wow that fixed it thank you and the indentation was just me being new to this sight so i probably just messed it up – llama Apr 10 '18 at 04:04
1

You don't need a loop. Python has a sum function

total = sum(integers) 
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245