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']]
2.1m questions
2.1m answers
60 comments
57.0k users