In: Computer Science
Write a statement that creates a list with the following string
numbers:
‘9’, ‘5’, ‘12’, ‘31’, ‘4’, and
‘8’.
Assume listDATA references this data list. Write a for-loop that displays each element of this list and the total of all these numbers
in python programming
def test():
#list having all number in string form
listDATA=['9', '5', '12', '31', '4', '8']
sum=0
for i in listDATA: #for each list element
print(i,end=" ") #print element
space seperated
sum=sum+int(i) #calculate sum
print()
print(sum) #print sum
test()
output
9 5 12 31 4 8
69