How can I check if two lists have same values at specific index, using slice?
L1 = ['X00013', 9654123, 4.1, 'No', 'No', 1.83, 3.8, 0.01, 90.01]
L2 = ['X00014', 2021230, 1.23, 'Yes', 'No', 1.86, 3.65, 0.15, 0.00001]
I know how to check
if L1[3] == L2[3]:
print("YES")
but I do not know how to check for multiple locations/indices at the same time:
I'm looking for something like checking both lists at indices 3,4 and 7 at the same time.
I can use operator and itemgetter
:
itemgetter(3,4,7)(L1) == itemgetter(3,4,7)(L2)
but I would like the simple direct solution slicing the lists. Thank you for your help.