Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a list with the characters of a string? [duplicate]

Is it possible to transform a string into a list, like this:

"5+6"

into

["5", "+", "6"]
like image 938
user678766 Avatar asked Mar 31 '11 14:03

user678766


People also ask

How do you make a string repeating characters?

Java has a repeat function to build copies of a source string: String newString = "a". repeat(N); assertEquals(EXPECTED_STRING, newString);

How do I make a list of strings?

To create a list of strings, first use square brackets [ and ] to create a list. Then place the list items inside the brackets separated by commas. Remember that strings must be surrounded by quotes. Also remember to use = to store the list in a variable.


1 Answers

list('5+6')

returns

['5', '+', '6']
like image 147
eumiro Avatar answered Oct 02 '22 11:10

eumiro