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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:12:57+00:00 2026-06-08T08:12:57+00:00

I have a list with two elements like this: list_a = [27.666521, 85.437447] and

  • 0

I have a list with two elements like this:

list_a = [27.666521, 85.437447]

and another list like this:

big_list = [[27.666519, 85.437477], [27.666460, 85.437622], ...]

And I want to find the closest match of list_a within list_b.

For example, here the closest match would be [27.666519, 85.437477].

How would I be able to achieve this?

I found a similar problem here for finding the closest match of a string in an array but was unable to reproduce it similarly for the above mentioned problem.

P.S.The elements in the list are the co-ordinates of points on the earth.

  • 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-08T08:13:00+00:00Added an answer on June 8, 2026 at 8:13 am

    From your question, it’s hard to tell how you want to measure the distance, so I simply assume you mean Euclidean distance.

    You can use the key parameter to min():

    from functools import partial
    
    def distance_squared(x, y):
        return (x[0] - y[0])**2 + (x[1] - y[1])**2
    
    print min(big_list, key=partial(distance_squared, list_a))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have input of a list with elements like this: calendar year 2008
I have a wordpress list with just two elements and I would like to
I have a list of elements, which are styled like this: ul { list-style-type:
I have two different list types. I need to remove the elements from list1
I have two lists. They are sortable but not connected (elements of list one
We have two lists: a=['1','2','3','4'] b=['2','3','4','5'] How to get a list with elements that
I have two list: list_a = [<User: x>, <User: y>] list_b = [False, True]
Suppose I have a bulleted list like this: * list item 1 * list
I have a list like this: <html> <head> <link type=text/css rel=stylesheet href=testli.css> </head> <body>
Say I have a list of Strings with the elements: One, Two, Three, Four

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.