Taking the sum and average of the keyboard inputs I have an assignment as follows:


  Write a program where you can enter from the keyboard up to 10
  integers. If the number entered is equal to -99, stop reading numbers
  from the keyboard and compute the average and sum of all values
  (excluding -99). Print the average on the screen. Make sure you
  consider all the cases: less than 10 or exactly 10 numbers can be
  entered. After the numbers have been entered you need to make sure
  that the average is computed then.


I came up with the program below. Do you think my program is fine? What could be alternative solutions?

s = 0
for i in range(1, 11):
    a=int(input("Enter a number: "))
    if a==-99:
        s = s+a
        print("The sum of the numbers that you've entered excluding -99:",s-a) # minus a because we want to exclude -99
        print("The average of the numbers that you've entered excluding -99:",(s-a)/(i-1)) # minus a because we want to exclude -99. i-1 in denominator because we excluded -99 from the sum.
        break
    else:
        s = s+a
        print("The sum of the number(s) that you've entered:",s)
        print("The average of the number(s) that you've entered:",s/i)
        continue
input("Press enter to close")
A few things:

The application should do 2 things.


  
  Collect up to 10 different integers, or until the entered value is -99
  Sum and Average the values
  


# so lets start by creating a list and fill it with all the numbers we need
numbers = list() 
for i in range(0, 10): 
    inputNr = int(input("Enter a number: "))
    if(inputNr == -99):
        break;

    numbers.append(inputNr)

#Then we take all of the numbers and calculate the sum and avg on them
sum = 0
for j, val in enumerate(numbers):
    sum += val

print("The total sum is: " + str(sum))
print("The avg is: " + str(sum / len(numbers)))


A few pointers about your code:


Use a whitespace (a single space) between variable declaration and assignment. Where you did a=1 you want to do a = 1
You usually iterate an array (or in Pythons case a list) from 0 to N, and not 1 to N
Create variables which you can reuse. As you can see in my example I create a inputNr variable which holds the input. I later reuse this to check if it's -99 and I reuse it by adding it to my list
variable names, function names, and everything else should have a descriptive and concise name. Where you named your input variable to a I named mine to inputNr. This means that when we later reuse this variable in the code it will be clear to us what it is and what it holds.