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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:08:43+00:00 2026-06-18T12:08:43+00:00

I followed the top solution to Flattening an irregular list of lists in python

  • 0

I followed the top solution to Flattening an irregular list of lists in python (Flatten (an irregular) list of lists) using the following code:

def flatten(l):
    for el in l:
        if isinstance(el, collections.Iterable) and not isinstance(el, basestring):
            for sub in flatten(el):
                yield sub
        else:
            yield el


L = [[[1, 2, 3], [4, 5]], 6]

L=flatten(L)
print L

And got the following output:

“generator object flatten at 0x100494460”

I’m not sure which packages I need to import or syntax I need to change to get this to work for me.

  • 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-18T12:08:44+00:00Added an answer on June 18, 2026 at 12:08 pm

    You can iterate the generator object directly:

    for x in L:
        print x
    

    or if you truly need a list, you can make one from it:

    list(L)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed the top answer here, see below for code to get system memory
Ok, i followed this tutorial (code is down below on the page, just top
I followed this video tutorial for detecting memory leaks using Instruments with Xcode 4.3.2.
I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
The layout is basic: an EditText at the top followed by a ListView. EditText
In the top-voted answer to this fantastic question , the following regular expression is
I am trying to order the data in the table by using the following
I have followed the article Layout Tricks: Using ViewStubs to set a View on
I followed the following tutorial to help me create a datagrid ( http://www.asp.net/web-pages/videos/aspnet-razor-pages/displaying-data-in-a-grid ),
I'm following railscast and have followed the instructions exactly. I've even used net.tutsplus's faye.ru

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.