Help me to compare elements in different lists in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help me to compare elements in different lists in python

Python list

19th Jul 2020, 3:41 PM
Anjana M
Anjana M - avatar
2 Answers
0
You can use a loop to go through the elements. https://code.sololearn.com/cCN7FxoSQpRd/?ref=app
19th Jul 2020, 3:47 PM
Arnesh
Arnesh - avatar
0
# List Comprehension: # ["output" for "item" in "list" if "filter"] import numpy as np x = list(np.random.randint(1,100,30)) y = list(np.random.randint(1,100,30)) print('x =',x) print('y =',y) print('Similar =',sorted([xy for xy in x and y if xy in x and y]))
19th Jul 2020, 4:08 PM
Steven M
Steven M - avatar