1.
A function named
reverse
takes a string argument, reverses it, and returns the result:def reverse(astring): """Returns the reverse of `astring`"""
Complete the assert statements in the ActiveCode editor below to create a unit test for
reverse
. Your asserts should check that reverse
works properly for the following test cases (“Input” refers to the value passed as a parameter, and “Expected Output” is the result returned from reverse
):Input Expected Output -------- --------------- Test Case 1: 'abc' 'cba' Test Case 2: 'b' 'b' Test Case 3: '' ''
Hint.
If you’re not sure how to get started with this one, review Section 20.5.
Solution.
assert reverse('abc') == 'cba' assert reverse('b') == 'b' assert reverse('') == ''