# # Name: CS 111 Course Staff # # lab4task3.py # def remove_spaces(s): """ uses recursion to return a version of the string s with spaces removed. input: 's' is an arbitrary string """ if s == '': return '' else: rest_no_spaces = remove_spaces(s[1:]) if s[0] == ' ': return rest_no_spaces else: return s[0] + rest_no_spaces # optional test function def test(): test1 = remove_spaces('a b c d') print('first test returns', test1) test2 = remove_spaces(' fine thanks! ') print('second test returns', test2) test3 = remove_spaces(' a b ') print('third test returns', test3)