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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:20:46+00:00 2026-05-15T02:20:46+00:00

This is probably a really silly question but, given the example code at the

  • 0

This is probably a really silly question but, given the example code at the bottom, how would I get a single list that retain the tuples?

(I’ve looked at itertools but it flattens everything.)

What I currently get is:

(‘id’, 20, ‘integer’)
(‘companyname’, 50, ‘text’)
[(‘focus’, 30, ‘text’), (‘fiesta’, 30, ‘text’), (‘mondeo’, 30, ‘text’), (‘puma’, 30, ‘text’)]
(‘contact’, 50, ‘text’)
(’email’, 50, ‘text’)

Instead, I need a single level list:

(‘id’, 20, ‘integer’)
(‘companyname’, 50, ‘text’)
(‘focus’, 30, ‘text’)
(‘fiesta’, 30, ‘text’)
(‘mondeo’, 30, ‘text’)
(‘puma’, 30, ‘text’)

(‘contact’, 50, ‘text’)
(’email’, 50, ‘text’)

Code:

def getproducts():
    temp_list = []

    product_list = ['focus', 'fiesta', 'mondeo', 'puma']
    # usually this would come from a db

    for p in product_list:
        temp_list.append((p, 30, 'text'))
    return temp_list

def createlist():    
    column_title_list = (
       ("id", 20, "integer"),
       ("companyname", 50, "text"),
       getproducts(), 
       ("contact", 50, "text"),
       ("email", 50, "text"),
    ) 
    return column_title_list

for item in createlist():
    print item
  • 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-15T02:20:47+00:00Added an answer on May 15, 2026 at 2:20 am

    Can you make it into

    [[("id",20,"integer")],
     [("companyname",50,"text")],
     getproducts(),
     ...]
    

    ? If so, you just need to concatenate the lists.

    return sum(column_title_list, [])
    

    You could also use

    return [("id",20,"integer"),("companyname",50,"text")] + getproducts() + ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey Everyone, This question seems really silly to me, but I can't for the
This is probably a silly question but i haven't been able to find the
This is probably really simple but i cant figure it out. Take a look
Ok, so I am fairly new to webdeveloping, so probably a silly question: I
I am no good with hardware concepts. So I have this probably very silly
this code was working fine till this morning, can anyone spot my mistake? probably
I'm having a really silly issue... basically I'm working on a site on a
As you know, the headers_list() -PHP-function returns an array like this: Array ( [0]
So, I am in the process of learning Haskell, and am frequently falling to
I have a form where I'm using Jquery to submit the form to create

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.