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

  • Home
  • SEARCH
  • 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 6578255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:44:52+00:00 2026-05-25T15:44:52+00:00

I am learning python and panda3d currently. I have a nested list which i

  • 0

I am learning python and panda3d currently.
I have a nested list which i need to convert into a list of coordinates.

my input is

    [['g,g', 'g,g'], ['d,d', 'd,d,d', 'd,d], ['s,s', 's,s']]

The Output that I need is another list:

    [(0,0,0,'s'),(0,1,0,'s'),(1,0,0,'s'),(1,1,0,'s'),(0,0,1,'d'),(0,1,1,'d'),(1,0,1,'d'),(1,1,1,'d'),(1,2,1,'d'),(2,0,1,'d'),(2,1,1,'d'),(0,0,2,'g'),(0,1,2,'g'),(1,0,2,'g'),(1,1,2,'g')]

this simple list conversion is scrambling my brain. o.0

EDIT: more info:
in the input list, the last nested list represents the base layer.

The idea was to convert string i have written in a file into coordinate points. This is the content of the file:

    [LVL02]
    g,g
    g,g
    [/LVL02]
    [LVL01]
    d,d
    d,d,d
    d,d
    [/LVL01]
    [LVL00]
    s,s
    s,s
    [/LVL00]

this should give me a very basic map maker. each level is a flat 2d surface.

    [LVL02]
    g,g             (0,0,2,'g'),(0,1,2,'g')
    g,g             (1,0,2,'g'),(1,1,2,'g')
    [/LVL02]
    [LVL01]
    d,d             (0,0,1,'d'),(0,1,1,'d')
    d,d,d           (1,0,1,'d'),(1,1,1,'d'),(1,2,1,'d')
    d,d             (2,0,1,'d'),(2,1,1,'d')
    [/LVL01]
    [LVL00]
    s,s             (0,0,0,'s'), 0,1,0,'s')
    s,s             (1,0,0,'s'),(1,1,0,'s')
    [/LVL00]

ie. (xaxis,yaxis,zaxis, type)

  • 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-25T15:44:52+00:00Added an answer on May 25, 2026 at 3:44 pm

    It might be this:

    l = [['g,g', 'g,g'], ['d,d', 'd,d,d', 'd,d'], ['s,s', 's,s']]
    output = [ (x, y, z, v) for z, l1 in enumerate(l[::-1]) for y, l2 in enumerate(l1) for x, v in enumerate(l2.split(',')) ]
    

    … but as it has been written, it is not clear what the rule is exactly. In nested loops:

    output = []
    for z,l1 in enumerate(l[::-1]):
        for y, l2 in enumerate(l1):
            for x, v in enumerate(l2.split(',')):
                output.append((x, y, z, v))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

WARNING: I have been learning Python for all of 10 minutes so apologies for
I'm learning Python now because of the Django framework. I have been a Perl
I'm learning Python, and I have a situation where I want to consume items
Is there an online Java book like Dive into Python for learning Python? Other
I learning Python (coming from a dotnet background) and developing an app which interacts
I am learning Python for a class now, and we just covered tuples as
I've been learning python for a while now with some success. I even managed
I recently started learning Python and I was rather surprised to find a 1000
I am learning Python and trying to figure out an efficient way to tokenize
I was just reading through Learning Python by Mark Lutz and came across this

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.