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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:03:52+00:00 2026-06-13T11:03:52+00:00

Edit: I’ve realized my error (if statement, variable x is assigned to element in

  • 0

Edit: I’ve realized my error (if statement, variable x is assigned to element in string and i’m comparing to length of list).. Trying to resolve that tomorrow morning. Appologies for the stupid error but i would appreciate any bits of learning.

I’m trying to combine two lists into a single list.

 m = [1,2,3]
 n = [4,5,6]
 v = m+n

 def myFun():
   return [(str(x)+str(y)) for x in m if x < len(m) for y in n if y < len(n)]

 print(myFun())

the result of myFun() should display “14, 25, 36”

i also tried to breakdown the code into a more pythonic world and have seen where i’ve gone astray:

 def my(fun()):
   for x in m if x < len(m):
     for y in n if y < len(n): # problem here, running until count 9 instead of 3
                               # like it's supposed to.. author error.. 
       newlist.append(str(x)+str(y))
   print(newlist)

Am i even headed in the right direction or should i be trying to build a map, i’ve seen a few pages saying that maps could be counter-productive if you have to reverse with a list-comp or lambda? Also, is it possible to count a specific object inside a list comprehension / lambda? (e.g. list length)?

  • 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-13T11:03:53+00:00Added an answer on June 13, 2026 at 11:03 am

    use zip():

    In [8]: m = [1,2,3]
    
    In [9]: n = [4,5,6]
    
    In [10]: [str(x)+str(y) for x,y in zip(m,n)]
    Out[10]: ['14', '25', '36']
    

    or use itertools.izip_longest() if the lists are of different lengths:

    In [2]: m=[1,2,3]
    
    In [3]: n=[4,5,6,7]
    
    In [4]: from itertools import izip_longest
    
    In [5]: [str(x)+str(y) for x,y in izip_longest(m,n,fillvalue="")]
    Out[5]: ['14', '25', '36', '7']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
I'm trying to create an if statement in PHP that prevents a single post
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
EDIT: iam using ajax to load text in my content that is why onload
Edit : Note that, as Daniel and latkin noted in an answer and a
EDIT : It turned out that this can only be done through an external
EDIT: Sorry about ellipsis that's not what I actually have. For declaring an array
Edit: Updating post based on Martins comments below Hello, I'm just trying to get
EDIT: changed the whole question sorry, im trying to deal with the mysql DATETIME

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.