i have a list of two string tuples: For example purposes i use this list of tuples but of course the list is generally longer:
[("Hello world","1"), ("Helloworld","2"),("Hi, Hello world","1"),("How are you","3"),("HiHelloworld","2")]
The two strings of the tuple are the messages and the sender ID, these messages are of variable length, the only thing that doesn't change is the sender ID. I find myself with a list with multiple messages of different length with the same sender ID, i just want to get a list with the longest message of each sender: e.g. in my example would be:
[("Hi, Hello world","1"),("How are you","3"),("HiHelloworld","2")]
I'm a little bit confused as i don't often work with tuples so i really don't know how to procede. I know i should sort the list before doing anything, that's ok, i know to do this but how do i the longest string for each sender after that, knowing that each element of the list is not a string or integer but a tuple?
Thank you very much!