Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sum
#1
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
Reply
#2
What have you thought about? Programming is an exercise in problem solving, so work it out! How would you work it out on paper?
Reply
#3
(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
Reply
#4
can someone help ?
Reply
#5
So the hint was that you had written the first part in Title sum.
>>> ab = [4, 10, 18]
>>> sum(ab)
32
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020