def str_to_list_from_splitter(string: str, spliter: str) -> list: lst = list(string.split(spliter)) return lst str_1 = 'zamazingo mamamingo lamamingo' str_2 = 'greyfurt, elma, armut, kiraz' print(str_to_list_from_splitter(str_1, ' ')) print(str_to_list_from_splitter(str_2, ','))
Result
['zamazingo', 'mamamingo', 'lamamingo'] ['greyfurt', ' elma', ' armut', ' kiraz']