Make 2 lists a=[1,2,3,4] b=[9,8,5,5,2,3,3,4,1,1,10,9,2,3,4,10,10,9,7,7,8] Write a program to remove duplicate of b and keep only those elements of b which are not present in a, and the final list should be shorted in ascending order. Make the same program by optimising code.

AnswerBot
6mo

Remove duplicates from list b, keep elements not in list a, and sort in ascending order.

  • Create a set from list b to remove duplicates

  • Use list comprehension to keep elements not in list a

  • Sort the final...read more

Anonymous
author
8mo
1. C=[I for in set(b) if i not in c] 2. C=[{b}-{a}]
Help your peers!
Add answer anonymously...
Nielsen Data Scientist Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter