0

Как преобразовать a = [[15530], [15531], [15537], [15534]] в b = [15530, 15531, 15537, 15534]

3 ответа 3

3

Надо взять первый элемент каждого списка

b = [el[0] for el in a]
2
b = []
a = [[15530], [15531], [15537], [15534]]
for i in a:
    b.append(i[0])

print(b)
# b = [15530, 15531, 15537, 15534]
1

Можно гораздо проще

b = sum(a, [])

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.