Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4344646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:55:36+00:00 2026-05-21T11:55:36+00:00

I am hoping someone can help me with a problem I’m stuck with. I

  • 0

I am hoping someone can help me with a problem I’m stuck with. I have a large number of tuples (>500) that look like this:

(2,1,3,6)  
(1,2,5,5)  
(3,0,1,6)  
(10,1,1,4)  
(0,3,3,0)  

A snippet of my code reads:

sum1 = (A,B,C,D) # creates a tuple of sums of (A,B,C,D)  
mysum = map(sum, zip(A, B, C, D))
print(mysum)

I realize the above code is not correct. I am trying to find a way to add all the values A together, all the values of B together, all the values of C together, and all the values of D together using the zip function. For example, I would like to print something that looks like this:

Asum = 16  
Bsum = 7  
Csum = 13  
Dsum = 21  

Can anyone help please? Thanks very much for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:55:37+00:00Added an answer on May 21, 2026 at 11:55 am
    >>> zip((1,2,3),(10,20,30),(100,200,300))
    [(1, 10, 100), (2, 20, 200), (3, 30, 300)]
    
    >>> [sum(x) for x in zip((1,2,3),(10,20,30),(100,200,300))]
    [111, 222, 333]
    

    To do this with an arbitrarily large set of tuples:

    >>> myTuples = [(1,2,3), (10,20,30), (100,200,300)]
    >>> [sum(x) for x in zip(*myTuples)]
    [111, 222, 333]
    

    sidenote: in python3, note that zip returns a lazy iterable, which you can always explicitly turn into a list like any other kind of iterable: list(zip(…))

    (thanks to Seganku for catching mistake in examples in an edit which was thrice rejected by other editors)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird problem that I am hoping someone can help me with.
I'm hoping someone can help me as I've been stuck on this problem for
I have a problem I'm hoping someone has come across and can help. I
I hoping someone can help me with a problem I'm stuck(again) with. if i
Im hoping someone can help me with a small problem! I have a php
Hoping someone can help with this. I have other VM's that dont have problems,
I am hoping that someone can help me with a problem I've got at
Good Morning Everyone, I am hoping that someone can help me with a problem.
I was hoping that someone can help me with this fancybox plugin issue. Problem
I'm really stuck with a problem I'm hoping someone can help me with. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.