tags:
- code
topic: List
difficulty: Easy
link:
date: 2023-10-28
Problem
Write a function to split a string and convert it to an array of words.
string_to_array("Python is the best!") # returns ["Python", "is", "the", "best"]
def string_to_array(s):
return s.split() if s!= '' else ['']
def string_to_array(string):
return string.split(" ")