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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:35:39+00:00 2026-06-03T06:35:39+00:00

I need to step some elements from a list (in this case n) I

  • 0

I need to step some elements from a list (in this case n)
I has also another list ( o list)

n=['A','B','C','D','E']
o=['A','B','C','D','E','AS','sd','Z','R']
n.sort()

Now if I use this code:

for o in sorted(n): 

The code is run for 'A','B','C','D','E'.

I need to run the for code but just only 'AS','sd','Z','R' items.

Something like : run the code for items from o list without items from n list

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

    This works only if o has no duplicates:

    n = ['A','B','C','D','E']
    o = ['A','B','C','D','E','AS','sd','Z','R']
    a = sorted(set(o) - set(n))
    
    # a == ['AS', 'R', 'Z', 'sd']
    

    otherwise use this:

    n = ['A','B','C','D','E']
    o = ['A','B','C','D','E','AS','sd','Z','R', 'AS']
    s = set(n)
    a = sorted(elem for elem in o if elem not in s)
    
    # a == ['AS', 'AS', 'R', 'Z', 'sd']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help implementing the Radix sort algorthim in JavaScript. I found this
I have a some computation program. Now, this program is a single-thread, I need
firstly, pardon my pseudo-code, i think in this case it is more legible than
I have some problems with performance in my code… I need to render many-colored
I have a list with N elements, and I slice it using certain step,
Very new to XSL (and XML for that matter), but I need to step
I have a longer running multi-step process using BackgroundWorker and C#. I need to
Need to insert selected text on the page into textarea. There must be some
Need to call a filter function on some options based on a radio selected
Need some help, please. I have a line of horizontal thumbnails loaded as ONE

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.