← Back to challenges

List from Comma-Delimited String

PythonHardstringsloops

Instructions

Write a function that turns a comma-delimited list into an array of strings.

Examples

to_array("watermelon, raspberry, orange")
➞ ["watermelon", "raspberry", "orange"]

to_array("x1, x2, x3, x4, x5")
➞ ["x1", "x2", "x3", "x4", "x5"]

to_array("a, b, c, d")
➞ ["a", "b", "c", "d"]

to_array("")
➞ []

Notes

Return an empty list for an empty string.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Mumbling Challenge