UrbanPro

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How to remove matching elements from two nested lists while iterating

Asked by Last Modified  

25 Answers

Learn Python

Follow 0
Answer

Please enter your answer

Trainer

for i in list_1: for j in list_2: if i==j: list_1.remove(i) list_2.remove(j)
Comments

IT Teacher

a= b= for i in a: if a in b: a.remove(i) b.remove(i)
Comments

for set in dataSet: for item in set: if item=="311472": dataSet.remove(item)
Comments

Train the students to shine in IT world.

Try with this: 1. Instead of deleting an element from the loop I would suggest you to try with the While loop. 2. Once when the iteration completed then delete the item lists which you would like to delete from the item list.
Comments

IT Teacher

Here is the code to do a= b= for i in a: if i in b: a.remove(i) b.remove(i) print("a:%s,b:%s",%(a,b))
Comments

Trainer

You can use list iterators, and can delete the elements while traversing the list.
Comments

l=,] flag = 0 for x in l: if (flag == 0): list1=x flag = 1 else: list2=x if : print("Number was found") list1.remove(item) list2.remove(item) else: print("Number not in list")
Comments

IT Professional Trainer with 15 years of experience in IT Industry

You could always iterate over a copy of the list, leaving you free to modify the original: for item in list(somelist): ... somelist.remove(item)
Comments

Expert Php Developer and Php Programing Teacher

in nested loop check if value is equal to parent while loop
Comments

Trainer

First unpack the nested list(L) into two separate lists (L1, L2). Then create a new list LC which contains common elements from L1 and L2. Iterate through LC, for each element 'elem', use L.remove(elem) and L.remove(elem)... Then display L. You will not see the matching elements in the two nested lis...
read more
First unpack the nested list(L) into two separate lists (L1, L2). Then create a new list LC which contains common elements from L1 and L2. Iterate through LC, for each element 'elem', use L[0].remove(elem) and L[1].remove(elem)... Then display L. You will not see the matching elements in the two nested lists.... read less
Comments

View 23 more Answers

Related Questions

Hi all, I'm looking for a tutor who can teach Data Structure, and also Object Oriented Programming w.r.t Python.
Hi, I'm a professional trainer and design consultant, and I do training on Python, AWS, C/C++. I do generally customize the training content and pace based on the student's absorbption level. I have trained...
Jigar

I want to learn Python but I dont know which tool is better for the future? and i want to get a job in less time. I am a fresher, 2017 passed out.

Congratulations for passing out in 2017. Learning Python programming language will help you get a job in less time provided you are good in general aptitude,computer science fundamentals. You need to become...
Srinu

I am working in a nontechnical field and i want to  switch this job and work in a technical field but I am not able to decide where to start. I want to learn, but what in Python?

I can help you make a blasting entry in technical profile. You can learn Informatica+Oracle and one real time project with me. It should be enough for your future growth.
Raksha
I want full details of the Python training, topics covered timing and duration. How much Fee for full course?
We conduct hands-on Python workshop at Kochi with personal attention to each participant. Classes with a batch of l1 or 2 students are also conducted based on the convenience of learner and tutor. Workshop...
Ravi

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Multiple Decorators
#Multiple decorators can be chained in Python.#A function can be decorated multiple times with different (or same) decorators.#We simply place the decorators above the desired function. def star(func):...

What is a generator?
A generator is a function that has one or more yield statements. Example: >>>def gen_demo(a): yield a a = a+10 yield a a = a+30 yield a >>>gen_a...

Python Programming
Python is a widely used general-purpose, high-level programming language. This is an Open Source Software and its source code is available with a license in which the Copyright holder provides the rights...

Use IPython shell for better understanding of python
Hi All, Even though there are many editors like IDLE, PyDev, PyCharm are available for python, it is very advantageous to use ipython as an interactive shell for Pyhon. How to install it? pip install...

Using Lambda and Filter with Regular expressions.
1) Start the Python interpreter and import the re module: >>> import re 2)Define a tuple strings to filter with regular expressions: t=('python','pycon','perl','peril','step','stop','come','came','exercise','hello','storm','my.mail','year','yam') ...

Recommended Articles

Python is one of the most popular programming languages in the world. It is general-purpose, object oriented, high-level programming language used in a number of programming fields. Python is a great programming language to learn as it will introduce you to the world of programming. If you are from the technical background...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...

Read full article >

Looking for Python Training classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more