Let's say, there is a string that can be:
- "3d6"
- "t3d6"
- "3h4d6"
- "t3h4d6"
- "6 t3d6"
- "6 t3h4d6+6" and similar possible variations.
Is there a way to run through the string and add the items from it to the list based on them being letters/numbers/symbols/other stuff? For example, "6 t3h10d6+6"
would result in [6, " ", "t", 3, "h", 10, "d", 6, "+", 6]
as the list.
I'm working on a telegram bot that uses the python to answer users' inputs with dice calculations results and the hardest part is processing the user input. Right now the input is being processed through the clumsy if statements complex. There might be a better way to process the user input and I would be glad to hear your advice!
Not a duplicate to this question. The question is about breaking a string into list of characters, basically turning a string into a list of strings. My question is about breaking string into list of different items that can be both strings and integers.