0

How to get a common list from lists in Python ?

I have 2 lists List1 = [1,2,3,4] List2 =[4,5,6,7] The output is list3 =[4]

14th Jul 2019, 3:58 AM
Nguyễn Duy
Nguyễn Duy - avatar
4 ответов
+ 2
A similar question concerning collections may help. https://www.sololearn.com/Discuss/1687534/?ref=app
14th Jul 2019, 5:11 AM
Louis
Louis - avatar
+ 2
Here's a simple answer list1 = [1, 2, 3, 4] list2 = [4, 5, 6, 7] list3 = [i for i in list1 if i in list2] print(list3)
15th Jul 2019, 12:47 AM
David Ashton
David Ashton - avatar
0
This looks like a homework problem Kindly show your efforts first
14th Jul 2019, 4:10 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
David Ashton I see python makes life a lot easier!👍👌
15th Jul 2019, 4:35 AM
Saurabh Tiwari
Saurabh Tiwari - avatar