Вы можете использовать chain.from_iterable()
, чтобы избежать двойного цикла for
в понимании списка:
from itertools import chain
l = [["testo=text1", "testo2=text2"], ["testo3=text3", "testo4=text4"]]
[i.split('=') for i in chain.from_iterable(l)]
# [['testo', 'text1'], ['testo2', 'text2'], ['testo3', 'text3'], ['testo4', 'text4']]
Объяснение, почему ваше решение не работает:
splitted_params = [["testo=text1", "testo2=text2"], ["testo3=text3", "testo4=text4"]]
print([i for i in splitted_params] == splitted_params)
# True
Таккогда вы используете [i for i in splitted_params]
внутри вашего listcomp, вы получаете тот же список.