I was attempting the credit problem in problem set 1 from CS50,
and i was stuck at adding the digits of numbers after multiplying them by 2.
When i used sum(), i got sum of numbers so if there is a two digit number in my list it will add the number itself to other single digit numbers and not the individual digits of the numbers.
list1 = [0,4,1,2,3,2,8,9,6] x= int(len(list1)) ## multiplying each number in list by 2. for index in range(x): product1 = [i*2 for i in list1] print(product1) this returns >>> [0,8,2,4,6,4,16,18,12] now if i use sum(product1) i get 0+8+2+4+6+4+16+18+12 = 70 however, what i want to do instead is 0+8+2+4+6+4+1+6+1+8+1+2 = 43
how can i acheive this.
Thanks in advance.