alphabet learning toy on gray apparel
Photo by Ryan Wallace on Unsplash

This is another quick article in which we are going to see how to do a conversion of a string into a list of characters in a single line in Python.

Let us take an example of a string that we want to convert into a list:

Now, all we have to do is put the string as a parameter inside list().

Yes, it’s that simple. No need to write list comprehensions, or using the split method.

Let me repeat that again: You can pretty much simply use list() and you are going to get the string converted into a list of characters.

Before we show that, let us see how we would do that in an intuitive way. We can consider each character in a string as an element, so we need to iterate through the characters just as we do with iterating through a list of elements.

Here is the example:

Now let us see list(), which can be considered more Pythonic.

I do agree that this can not be that much of a big deal but can be quite fun using it from time to time.

That is all for this article. I hope you find it useful.