A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a Python program to remove all elements from a given list present in another list
Q:

Write a Python program to remove all elements from a given list present in another list

0

Write a Python program to remove all elements from a given list present in another list

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def index_on_inner_list(list1, list2):
    result = [x for x in list1 if x not in list2]
    return result

list1 = [1,2,3,4,5,6,7,8,9,10]
list2 = [2,4,6,8]

print("Original lists:")
print("list1:", list1)
print("list2:", list2)

print("\nRemove all elements from 'list1' present in 'list2:")
print(index_on_inner_list(list1, list2))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now