Write a function tail_of_result_is_ok(arglist, i, result) that will be called by the assert at the end of each iteration of the loop shown above. The purpose of this function is to check the relationship that the tail of the string result should have with the ith element of arglist. You have to figure out what this relationship must be. Think about what relationship the idxth element of arglist must have with the string result at the point immediately after the line of codedef concat_elements(arglist, startpos, stoppos): result="" if startpos < 0: startpos = 0 if stoppos >= len(arglist): stoppos = len(arglist)-1 idx = startpos while idx <= stoppos: result += arglist[idx] idx += 1 assert tail_of_result_is_ok(arglist, idx, result) return result
result += arglist[idx]Now consider what you can say about this same relationship at the point in the code where the assert is shown (above). Your function tail_of_result_is_ok(arglist, idx, result) should return True if this relationship is in fact satisfied given the values of arglist, idx, and result at the point where the assert is made; and False if it is not.