Answer:
lst1 = [4, 3, 2, 6, 2]
lst2 = [1, 2, 4]
new_lst = []
for i in lst1:
if i in lst2:
new_lst.append(i)
new_lst.sort()
print(new_lst)
Step-by-step explanation:
The code is written in python.
lst1 = [4, 3, 2, 6, 2]
The variable lst1 represent a list of integers.
lst2 = [1, 2, 4]
The variable lst2 represent a list of integers.
new_lst = []
An empty variable is created new_lst and it is used to store the values of lst1 that is in lst2.
for i in lst1:
The code loop through integers in lst1.
if i in lst2:
This code means if any of the value in lst1 is in lst2.
new_lst.append(i)
This code put the same values found in lst1 and lst2 in a new list(new_lst)
new_lst.sort()
We sort the value of the new list from the smallest to the biggest.
print(new_lst)
The new list is displayed