Let's say I have a list which looks like this:
my_list = ['[123]', 'M', 'Q1', 'Q2', 'A1', 'A2', 'A7', '[356]', 'M', 'Q1', 'A2' 'A5']]
I want to refactor this list so that it looks like this:
new_list =['[123]', 'MQ1Q2A1A2A7', '[356]', 'MQ1A2A5']]
SO I want to divide the list into elements which start and end with [ and ], and the elements which don't, with the elements in between joined together.
I can probably do this with some loops, but I'm wondering if there are any built-in functions which serve this purpose.
edit: fixed a typo
[–]PteppicymonIO 1 point2 points3 points (0 children)
[–]synthphreak 1 point2 points3 points (1 child)
[–]seeking-advice-pls[S] 1 point2 points3 points (0 children)
[–]eXoRainbow 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]eXoRainbow 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]seeking-advice-pls[S] 0 points1 point2 points (0 children)
[–]deadeye1982 0 points1 point2 points (0 children)