Chrome Extension

Split string to list python

You can convert or split your string to a list in python using .split() method
my_str = "This is a string"
#output - ["This", "is", "a", "string"]

comma_str = "Apple, Banana, Orange"
print(comma_str.split(", "))
#output - ["Apple", "Banana", "Orange"]
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

In this code snippet, we convert a string to a list and split them using space and for the second variable, we split them using commas.

Was this helpful?
Join Devsheet Ask a Question