How to convert a string to list in Python?


I have a string great and I want to convert it into a list of characters like ['g','r','e','a','t']

How can I do that?

2 Answers

4 years ago by

Very simple way,

you can use the list() constructor

a = "great"
print(list(a))

check output here

4 years ago by Divya

def Convert(string):
lists = list(string.split("-"))
return lists

str1 = "Enter your string"
print(Convert(str1))

2 years ago by Sarvesh