Python 3.8.1
n = 10
a = []
while n != 0:
b = int(input('Enter number 1 - 30: '))
n -= 1
if b <= 10:
a.append(b)
if len(a) == 10:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
elif len(a) == 9:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8]
elif len(a) == 8:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
elif len(a) == 7:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]
elif len(a) == 6:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5]
elif len(a) == 5:
c = a[0] + a[1] + a[2] + a[3] + a[4]
elif len(a) == 4:
c = a[0] + a[1] + a[2] + a[3]
elif len(a) == 3:
c = a[0] + a[1] + a[2]
elif len(a) == 2:
c = a[0] + a[1]
elif len(a) == 1:
c = a[0]
else:
c = 0
print(c);
q = int(input('Enter any number to quit'))
Python 3.8.1
n = 10
a = []
while n != 0:
b = int(input('Enter number 1 - 30: '))
n -= 1
if b <= 10:
a.append(b)
if len(a) == 10:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8] + a[9]
elif len(a) == 9:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7] + a[8]
elif len(a) == 8:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6] + a[7]
elif len(a) == 7:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]
elif len(a) == 6:
c = a[0] + a[1] + a[2] + a[3] + a[4] + a[5]
elif len(a) == 5:
c = a[0] + a[1] + a[2] + a[3] + a[4]
elif len(a) == 4:
c = a[0] + a[1] + a[2] + a[3]
elif len(a) == 3:
c = a[0] + a[1] + a[2]
elif len(a) == 2:
c = a[0] + a[1]
elif len(a) == 1:
c = a[0]
else:
c = 0
print(c);
q = int(input('Enter any number to quit'))