close

How to split string to Char Array in Python

Hello guys. How are you all? I hope you all fine. In this tutorial we will learn about how to split . string to Char Array in Python. so without wasting time lets learn about of this.

How to split string to Char Array in Python

  1. split string to Char Array in Python

    to split string to Char Array in Python just use list. By using list we can split string into a list. So from this method you can split string to Char Array in Python. So lets learn about of this without wasting time by given below example: var = 'Exerror' mylst = list(var) print(mylst) Output : ['E', 'x', 'e', 'r', 'r', 'o', 'r']

  2. How to split string to Char Array in Python

    to split string to Char Array in Python just use extend. By using extent() you can extend each character of the string into a list. So lets learn about of this without wasting time by given below example: mylst = [] var = 'Exerror' mylst.extend(var) print(mylst) Output : ['E', 'x', 'e', 'r', 'r', 'o', 'r']

  3. python string to char array

    To split string to Char Array in Python just use list. By using list we can split string into a list. So from this method you can split string to Char Array in Python. So lets learn about of this without wasting time by given below example: var = 'Exerror' mylst = list(var) print(mylst) Output : ['E', 'x', 'e', 'r', 'r', 'o', 'r']

Method 1: split string to Char Array in Python Using list

By using list we can split string into a list. So from this method you can split string to Char Array. So lets learn about of this without wasting time by given below example:

var = 'Exerror'
mylst = list(var)
print(mylst)

Output :

['E', 'x', 'e', 'r', 'r', 'o', 'r']

Method 2: Use extend()

By using extent() you can extend each character of the string into a list. So lets learn about of this without wasting time by given below example:

mylst = []
var = 'Exerror'
mylst.extend(var)
print(mylst)

Output :

['E', 'x', 'e', 'r', 'r', 'o', 'r']

Method 3: Use *operator

By using * operator you can split string to Char Array. So lets learn about of this without wasting time by given below example:

var = "Exerror"
print([*var])

Output :

['E', 'x', 'e', 'r', 'r', 'o', 'r']

Method 4: Use for loop

By using for loop operator you can split string to Char Array. So lets learn about of this without wasting time by given below example:

string = "studytonight"
to_array = [char for char in string]
print(to_array)

Output:

['E', 'x', 'e', 'r', 'r', 'o', 'r']

Conclusion

It’s all About this Tutorial. Hope all methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you?

Also, Read

Leave a Comment