my_list = [('T0931', 'AB', '0.7826705747628963'), ('T0932', 'AB',
    '0.63950861050628'), ('T0933', 'AB', '0.8960345460457968'), ('T0933',
    'AF', '0.8951297220212914'), ('T0933', 'BC', '0.8951297782393018'), (
    'T0933', 'CD', '0.8951298105762795'), ('T0933', 'DE',
    '0.8951299080330034'), ('T0933', 'EF', '0.8941510860547524'), ('T0932',
    'AB', '0.63950861050628'), ('T0933', 'AB', '0.8960345460457968'), (
    'T0933', 'AF', '0.8951297220212914'), ('T0933', 'BC',
    '0.8951297782393018'), ('T0933', 'CD', '0.8951298105762795'), ('T0933',
    'DE', '0.8951299080330034'), ('T0933', 'EF', '0.8941510860547524')]
import itertools
res = []
for key, value in itertools.groupby(my_list, lambda x: x[0]):
    l = []
for val in value:
    l.append(val)
res.append(l)
grouping items in a list of lists containing tuples python