# Развернуть строку (например "Abc" -> "cbA") def invert_string(string): str_left = "" str_right = "" for i in range(len(string)//2): str_left += string[-i-1] str_right = string[i] + str_right if len(string) % 2 > 0: return str_left + string[len(string)//2] + str_right return str_left + str_right ################################################# 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_palindrome1 = "Sir, I demand, I am a maid named Iris" test_palindrome2 = "Satire: Veritas" test_palindrome3 = "Saippuakivikauppias" string_tests = [test_string1, test_string2, test_palindrome1, test_palindrome2, test_palindrome3, ''] for i in range(len(string_tests)): verifier(f"INVERT_STRING TEST {i+1}", invert_string(string_tests[i]), string_tests[i][::-1])