Question: BEGINNER PYTHON HELP! I have to write a new function called test_reverse that automates testing of my strReverseI and strReverseR codes that reverse any string

BEGINNER PYTHON HELP!

I have to write a new function called "test_reverse" that automates testing of my "strReverseI" and "strReverseR" codes that reverse any string you put into the function (below). strReverseI and strReverseR will be arguments to test_reverse. This has to call the function (strReverseI and strReverseR) repeatedly, once for each test case, and compare the result returned by the called function to the expected result. test_reverse should report for each test case whether the actual result matches the expected result, e.g.

Checking(testing123) ... its value 321gnitset is correct!

Test cases and expected results should be stored in a tuple of tuples defined in test_reverse. test_reverse should include at least the following tests:

(('', ''),

('a', 'a'),

('xyz', 'zyx'),

('testing123', '321gnitset'),

('hello, world', 'dlrow ,olleh') )

test_reverse should return None.

<><><><><>HERE IS THE STRING REVERSE I AND R CODE I MADE THAT SHOULD WORK<><><><><>

import doctest

def strReverseI(word):

length = len(word) while (length > 0): wordy = word[length-1] length = length - 1 print(wordy, end="") return "" def strReverseR(word):

if (word == ""): return word else: return strReverseR(word[1:]) + word[0]

def main(): print(doctest.testmod()) print(strReverseR("Mason")) print(strReverseI("Mason")) main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!