31 lines
999 B
Python
31 lines
999 B
Python
|
# Развернуть строку (например "Abc" -> "cbA")
|
||
|
def invert_string(string):
|
||
|
str_left = ""
|
||
|
for i in range(len(string)):
|
||
|
str_left += string[-i-1]
|
||
|
return str_left
|
||
|
|
||
|
|
||
|
#################################################
|
||
|
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])
|