Hossein Hossein - 17 days ago 6
Python Question

How can I split a list item

I am trying to split the first item of a list to two items, for exapmle I am trying to convert:

l= [('pzibley/09.03', [8, 0, 2, 0, 0]), ('pzibley/09.01', [7, 2, 0, 0, 1])]


to:

l= [([pzibley], [09.03], [8, 0, 2, 0, 0]), ([pzibley] , [09.01], [7, 2, 0, 0, 1])]


I have tried several ways but since I am an amateur I'm not able to do this.

Answer
[tuple([j] for j in i[0].split('/')) + (i[1],) for i in l]

# [(['pzibley'], ['09.03'], [8, 0, 2, 0, 0]),
#  (['pzibley'], ['09.01'], [7, 2, 0, 0, 1])]
Comments