- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I remove the same element in the list by Python
Just remove return statement outside for block. It will work. Also last print statement should have remove_same instead of remaove_new
def remove_same(L1, L2): L1_copy = L1[:] for e in L1_copy: if e in L2: L1.remove(e) return L1 L1 = [1,2,3,4] L2 = [1,2,5,6] print(remove_same(L1, L2))
- How to remove an element from a list by index in Python?
- How can I list the contents of a directory in Python?
- How can I consistently remove the default text from an input element with Selenium?
- How can I remove the ANSI escape sequences from a string in python?
- Remove Tuples from the List having every element as None in Python
- How can I select an element by name with jQuery?
- Python program to compute the power by Index element in List
- How to remove an element from a list in Python?
- How to remove element from the specified index of the List in C#?
- How can I use the HTML5 canvas element in IE?
- Can I play the same sound more than once at the same time with HTML5?
- How can I select an element by tag name using jQuery?
- How can I remove items out of a Python tuple?