# "Ручной" аналог функции split() def split_string(string, separator): array = [] element = "" for i in string: if i != separator: element += i else: array.append(element) element = "" array.append(element) return array ################################################# def verifier(test_name, actual, expected): print(test_name) if actual != expected: print("=======> FAILED! <=======") print(f"Got value <{actual}>") print(f"Expected value is <{expected}>") else: print("PASSED") print() test_string1 = "The World is not enough" test_string2 = "Testing is key" test_split1 = "1, 2, 3, 4, 5, 6, 7, 8, 9" test_split2 = "1 2 3 4 5 6 7 8 9" test_split3 = "bagahajemanbdneorijahdhrea4" split_string_tests = [test_split1, test_split2, test_split3, test_string1, test_string2, ''] for i in range(len(split_string_tests)): separator = ',' verifier(f"SPLIT_STRING (SEPARATOR='{separator}') TEST {i+1}", split_string(split_string_tests[i], separator), split_string_tests[i].split(separator)) for i in range(len(split_string_tests)): separator = ' ' verifier(f"SPLIT_STRING (SEPARATOR='{separator}') TEST {i+1}", split_string(split_string_tests[i], separator), split_string_tests[i].split(separator))