I have a returned string from a function such:
"& True True & True False & False"
I need to write a function that puts all the elements between & in a list and deletes it, such:
&
[[True, True], [True, False], [False]]
How do I do it? thanks in advance!
you can use split
l = "& True True & True False & False" result = [j.split() for j in l.split('&') if j!=''] print(result)
output
[['True', 'True'], ['True', 'False'], ['False']]
1.4m articles
1.4m replys
5 comments
57.0k users