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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:41:41+00:00 2026-06-01T06:41:41+00:00

Possible Duplicate: How do I randomly select an item from a list using Python?

  • 0

Possible Duplicate:
How do I randomly select an item from a list using Python?

I have two arrays pool_list_X , pool_list_Y. Both have a numpy array as element in the list.
So basically

pool_list_x[0] = [1 2 3 4] # a multidimensional numpy array.

and every element of pool_list_x has corresponding element in pool_list_y

which is to say, that pool_list_x[i] corresponds to pool_list_y[i]

Now. if I have to randomly select 10 elements from list_x (and hence the corresponding elements to list_y). how do i do this.
I can think of a very naive way.. randomly generate numbers. and stuff.. but that is not very efficient.. what is the pythonic way to do this.
Thanks

  • 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-01T06:41:42+00:00Added an answer on June 1, 2026 at 6:41 am

    Not sure if I understand you one hundred percent, but I think using zip and random.sample might work:

    import random
    random.sample(zip(list_a,list_b), 10)
    

    Some short explanations:

    • zip will create a list of pairs, i.e. it ensures that you pick corresponding elements – if you pick one, you automatically get the other (Zip([1,2,3],[4,5,6]) = [(1,4),(2,5),(3,6)])
    • random.sample(l,n) randomly selects n elements from a list l
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I randomly select an item from a list using Python?
Possible Duplicate: Select n random rows from SQL Server table I have database and
Possible Duplicate: Shuffling a list of objects in python IF I have a list:
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
Possible Duplicate: Split A4 PDF page into two A5 and back again I have
Possible Duplicate: How do I pick randomly from an array? What is the appropriate
Possible Duplicate: MySQL: Select Random Entry, but Weight Towards Certain Entries I have a
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have

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.