In: Computer Science
#Write a program in Python that given a list of positive
integers, return another list where each element corresponds to the
sum of the digits of the elements o#f the given list.
#Example:
# input
# alist=[124, 5, 914, 21, 3421]
# output
# sum=[7, 5, 14, 3, 18]
#Here the code starts
list=[] #declaring file to store values
n=int(input("Size of array:"))#taking size of array converting it
into integer
#taking list values
for i in range (0,n):
ele=int(input())
list.append(ele)
print(list) #printing original list
for i in range(0,n):
sum=0
while(list[i]!=0):
sum=sum+int((list[i]%10))#doing sum of digit
list[i]=(list[i]/10)
list[i]=sum #updating with new values
print(list)
#code ends here
Output:-