Python 3.6 - reading the the values of rows from two lists after a conditional statement

Viewed 71

Hi here is my code that looks for values that repeat 3 or more times in list a:

a = ['1','1','1','2','2','3']
b = ['4','5','1','7','8','4']

d = [item for item in a if a.count(item) >= 3]

print(d)
# ['1', '1', '1']

So my question is how can I also read the corresponding values in list b. Also list a and b are always the same size. My desired output should be:

output: [['1', '1', '1'], ['4', '5', '1']]

thank you!

3 Answers
Related