Answer the question
In order to leave comments, you need to log in
How to find the last common value in all the contents of a list and get the position number of the contents in the list?
There is such a list (the number of contents in it may vary):
rows = [('oops', 0, 'new1', 'AgACAgIAAxkBAAISxl78VN0h', 4, 4821, 2654700348373, '111111'),
('aaapp', 7000, 'test22222', 'AgACAgIAAxkBAAIVEl78g75SvLP7MlZTBkncHQ', 4, 5429, 7965418332586, '111111')]
rows = [('oops', 0, 'new1', 'AgACAgIAAxkBAAISxl78VN0h', 4, 4821, 2654700348373, '111111'),
('aaapp', 7000, 'test22222', 'AgACAgIAAxkBAAIVEl78g75SvLP7MlZTBkncHQ', 4, 5429, 7965418332586, '111111'),
('oops', 0, 'new1', 'AgACAgIAAxkBAAISxl78VN0h', 4, 4821, 2654700348373, '22222'),
('oops', 0, 'new1', 'AgACAgIAAxkBAAISxl78VN0h', 4, 4821, 2654700348373, '22222'),]
Answer the question
In order to leave comments, you need to log in
from itertools import groupby
print(
[
(k, list(l))
for k, l in
groupby(
enumerate(rows),
key=lambda row: row[1][-1]
)
]
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question