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('') == ''
