Python Forum

Full Version: sum
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i write this ode :
a = [1,2,3]
b = [4,5,6]
ab=[]
for i in range(0, len(a)) : 
    ab.append(a[i]*b[i])
print(ab)

and get :
Output:
[4, 10, 18]
now i trying to add 4+10+18 but dont know how to do it
please help
What have you thought about? Programming is an exercise in problem solving, so work it out! How would you work it out on paper?
(Mar-22-2020, 01:43 PM)dansht Wrote: [ -> ]now i trying to add 4+10+18 but dont know how to do it
You have already written part of the answer in Thread title,just missing (your_list) Think
can someone help ?
So the hint was that you had written the first part in Title sum.
>>> ab = [4, 10, 18]
>>> sum(ab)
32