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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:56:46+00:00 2026-05-12T06:56:46+00:00

Specifically, I have two lists of strings that I’d like to combine into a

  • 0

Specifically, I have two lists of strings that I’d like to combine into a string where each line is the next two strings from the lists, separated by spaces:

a = ['foo1', 'foo2', 'foo3']
b = ['bar1', 'bar2', 'bar3']

I want a function combine_to_lines() that would return:

"""foo1 bar1
foo2 bar2
foo3 bar3"""

I admit I’ve already solved this problem, so I’m going to post the answer. But perhaps someone else has a better one or sees a flaw in mine.

Update: I over-simplified my example above. In my real-world problem the lines were formatted in a more complicated manner that required the tuples returned from zip() to be unpacked. But kudos to mhawke for coming up to the simplest solution to this example.

  • 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-12T06:56:46+00:00Added an answer on May 12, 2026 at 6:56 am

    It’s not necessary to unpack and repack the tuples returned by zip:

    '\n'.join(' '.join(x) for x in zip(a, b))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a segfault coming from OpenSSL (specifically SSL_read ) that I'd like to
In python if I have two dictionaries, specifically Counter objects that look like so
I'd like to return a list of items of only those that have two
Say I have two lists or arrays of strings. For example: list 1: a,
I'd like to have two structures which point to eachother. Specifically, I'd like to
I have two tables with identical fields that share many rows. I'd like to
Or at least the part of it, that makes sense. More specifically I have
Are there any compression algorithms -- lossy or lossless -- that have been specifically
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().
I have read that GLSL (specifically v1.0.17: my application is running under WebGL) compilers

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.