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 8485225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:34:58+00:00 2026-06-10T20:34:58+00:00

So I have these tuples in two lists in another tuple which look like

  • 0

So I have these tuples in two lists in another tuple which look like

data_tuple = ([(1,2,3),(4,5,6)(7,8,9)],[(a,b,c),(d,e,f)(g,h,i)])

I want to build a set of coordinates using the corresponding indexed elements from each list, so that it looks like

final = [(2,b),(5,e),(8,h)]

Here’s what I got:

for a in data_tuple[0]:
    x = a[1]
    for b in data_tuple[1]:
        y = b[1]
        print(x,y)

For now I just wanna check if my iteration/indentation is right so I don’t need to put them in a list just yet. Right now the outcome for this particular code is

(2,b)
(2,e)
(2,h)
(5,b)
(5,e)

and so on until it reaches (8,h).

If I bring my print line to the left, under the second for loop, I get

(2,h)
(5,h)
(8,h)

How do I fix this? Sorry if I don’t make any sense =/. As you can tell I’m extremely new to Python so I’m not familiar with a lot of import modules. Any help please?

  • 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-06-10T20:35:00+00:00Added an answer on June 10, 2026 at 8:35 pm
    >>> print [(i[0][1],i[1][1]) for i in zip(*data_tuple)]
    [(2, 'b'), (5, 'e'), (8, 'h')]
    

    but often clarity is more important than brevity

    I dont really understand your original question since it looks like its working as intended that implies your indentation and iteration is fine..

    [edit] this is what you want i think

    for i in range(len(data_tuple[0]):
        x,y = data_tuple[0][i][1],data_tuple[1][i][1],
        print (x,y)
    

    or

    >>> for numbr,letr in zip(*data_tuple):
    ...     x,y = numbr[1],letr[1]
    ...     print(x,y)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these codes for my two tabs. I would like to change the
So I have a list of tuples of two floats each. Each tuple represents
I have a list of tuples pairing two pieces of data... I'd like to
I have some VTK-files, which look like this: # vtk DataFile Version 1.0 Line
Let's say I have the following two lists of tuples myList = [(1, 7),
I have two sequences (of tuples) on which I need to do a join:
I have these three lists with the same number of elements List<String>competitoinsIDs = new
I have these tables: Idea and poll (and others) which are types of what
I have these objects: public class Class { public Guid Id {get;set;} public string
I have these two lines in my web.xml <url-pattern>/</url-pattern> : Index Servlet and <url-pattern>/login</url-pattern>

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.