1
1
1 22021-08-29 10:17:21
Python
1 2, 2021-08-29 10:17:21

How to create a list from a string with certain criteria...?

How can I make from this line:

messageBefore = "[||~~6991~~||][||~~23838~~||][||~~-18993~~||][||~~4729~~||][**7**][||~~4713~~||][||~~367~~||]"

Such a list:
["||~~6991~~||", "||~~23838~~||", "||~~-18993~~||", "||~~4729~~||", "**7**", "||~~4713~~||", "||~~367~~||"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexbprofit, 2021-08-29
@weRifiCatoR

messageBefore = "[||~~6991~~||][||~~23838~~||][||~~-18993~~||][||~~4729~~||][**7**][||~~4713~~||][||~~367~~||]"

x = messageBefore.lstrip('[')
y = x.rstrip(']')

result = y.split('][')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question