J
J
Jekson2021-12-01 18:50:48
Python
Jekson, 2021-12-01 18:50:48

Add item to list of lists?

There is a list of lists construct

l = 

It is necessary to insert into each internal list at the first position a string formed from the first element of the list minus the WW_ part.
result = [items.insert(0, items[0].split('WW_')[1]) for items in l]

print(result)
Expected Result

The received result What not so I do?
[None, None, None]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-12-01
@Lepilov

newArr = [ [ n[0].split('_')[1], *n ] for n in arr ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question