I have two lists, the first one contains the names of people, and each person is associated with various symbols, for example, numbers, letters, for example:
listNameAge = ['alain_90xx', 'fred_10y', 'george_50', 'julia_10l','alain_10_aa', 'fred_90', 'julia_50', 'george_10s', 'alain_50', 'fred_50', 'julia_90']
The second contains the name of the person:
listName = ['fred', 'julia', 'alain', 'george']
Using the second list, I would like to associate the third list with the first, so that each name in the first list is associated with its index position in the second, that is:
thirdlist = [2, 0, 3, 1, 2, 0, 1, 3, 2, 0, 1]
The name and characters are separated by an underscore, but the character can be of any type. I could cycle through the elements listNameAge, separate the names of the faces from the rest of the characters using .split('_')in a string, find the name and find its index in listName, using the second loop.
I was wondering if there is an easier way to do this, i.e. avoid using a loop and use only a list of concepts?