I'm having a hard time trying to use another function into a function that tests the function I added with print statements. For example with this function that reverses a string. I want to use print statements in another function that tests the reverse function, but I'm having a hard time understand how I can incorporate the is_reverse function into the testing function without adding parameters into the testing function.
def is_reverse( st1, st2 ):
if len( st1 ) != len( st2 ):
return False
i = 0
j = len( st2 ) - 1
while j > 0:
if st1[i] != st2[j]:
return False
i += 1
j -= 1
return True
def test_is_reverse( ):
print( "is_reverse( \"hey\", \"yah\" ) == False.\"" )
print( "is_reverse( \"man\", \"nam\" ) == True.\"" )
Aucun commentaire:
Enregistrer un commentaire