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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:32:26+00:00 2026-05-12T16:32:26+00:00

biglist = [ {‘title’:’U2 Band’,’link’:’u2.com’}, {‘title’:’ABC Station’,’link’:’abc.com’}, {‘title’:’Live Concert by U2′,’link’:’u2.com’} ] I would

  • 0
biglist = 

[ 

    {'title':'U2 Band','link':'u2.com'}, 
    {'title':'ABC Station','link':'abc.com'}, 
    {'title':'Live Concert by U2','link':'u2.com'} 

]

I would like to remove the THIRD element inside the list…because it has “u2.com” as a duplicate. I don’t want duplicate “link” element. What is the most efficient code to do this so that it results in this:

biglist = 

[ 

    {'title':'U2','link':'u2.com'}, 
    {'title':'ABC','link':'abc.com'}
]

I have tried many ways, including using many nested “for …in ….” but this is very inefficient and too long.

  • 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-12T16:32:27+00:00Added an answer on May 12, 2026 at 4:32 pm

    You can sort the list, using the link field of each dictionary as the sort key, then iterate through the list once and remove duplicates (or rather, create a new list with duplicates removed, as is the Python idiom), like so:

    # sort the list using the 'link' item as the sort key
    biglist.sort(key=lambda elt: elt['link'])
    
    newbiglist = []
    for item in biglist:
        if newbiglist == [] or item['link'] != newbiglist[-1]['link']:
            newbiglist.append(item)
    

    This code will give you the first element (relative ordering in the original biglist) for any group of “duplicates”. This is true because the .sort() algorithm used by Python is guaranteed to be a stable sort — it does not change the order of elements determined to be equal to one another (in this case, elements with the same link).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my list: biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ] print random.shuffle(biglist) that doesn't
I want to write something like: var list = new List<int>(){1,2,3}; var bigList =
I would like to implement a settings activity which will look the same as
I have a big list, but micro example would be like the following: A
cache.set(key, Biglist, 3600) print cache.get(key) When my Biglist is a huge list of lots
I'm trying to set up (in Sharepoint), a mailing list archive. What I'd like
I'd like to get a big list (say 1,000 or more) of word phrases
Ok this is my problem. I am trying something like this: for i in
I find myself often wanting to write Python list comprehensions like this: nearbyPoints =
I have a problem, where i have big list of number pairs. something like

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.