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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:52:02+00:00 2026-05-13T20:52:02+00:00

I have a list which I have obtained from a python script. the content

  • 0

I have a list which I have obtained from a python script. the content of the list goes something like:
The content below is in a file but I loaded it into a list for comparing it to something else. But now I have to split this list such that each new list created contains the complex name with the corresponding number. Hope it is clear now 🙂

d.complex.1
24
25
67
123
764
d.complex.200
23
54
35
64
d.complex.302
.
.
.

I want to split this list such that, a new list is created from d.complex.1 to d.complex.2 (excluding d.complex.2) i.e.:

d.complex.1
24
25
67
123
764
end of list

>newlist
d.complex.200
23
54
35
64
endoflist

Can anyone help me out?
Cheers,
Chavanak

  • 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-13T20:52:03+00:00Added an answer on May 13, 2026 at 8:52 pm
    >>> mylist='d.complex.1\n24\n25\n67\n123\n764\nd.complex.200\n23\n54\n35\n64\nd.complex.302'.split("\n")
    >>> res=[]
    >>> for line in mylist:
    ...  if line.startswith("d.complex"):
    ...   res.append([])
    ...  res[-1].append(line)
    ... 
    >>> res
    [['d.complex.1', '24', '25', '67', '123', '764'], ['d.complex.200', '23', '54', '35', '64'], ['d.complex.302']]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 320k
  • Answers 321k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I found a program called "RevoSleep". Warning: MUSIC! http://revosleep.realspooky.de/ I… May 14, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer Just use the child selector >: $("#navigation > li") May 14, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer gcc -v prints out the configuration options among other stuff:… May 14, 2026 at 12:30 am

Related Questions

I have a C application we have deployed to a customers site. It was
Hey everyone, I am having a little trouble debugging my code. Please look below:
i have a list of say courses and certificates and fun_days . These are
I'm programming in Python with a wrapper of the kernel32 dll, so I can
I have a list which I've set item-level permissions on. I set it to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.