One of the most useful string operations in Python is split.
If we wanted to split "Free as in Freedom" into an array of words we would do.
array = "Free as in Freedom".split(" ")
We can pass any character(s) as an argument
array = "FreexasxinxFreedom".split("x")
Both would render the same array.
But how do we split a string into letters? With list.
List allows you to take a string or some other gathering of items (ints, arrays, etc) and split them into their individual items in an array. This is mostly used with strings.
This would split every character (including spaces) into an array.
Subscribe to Adventures In Techland
Get the latest posts delivered right to your inbox