For my assignment, I'm required to first come up with a function that reverses a string that is inputted (which I've already done using the code below)
def reverse(s):
if len(s) <= 1:
return s
return reverse(s[1:]) + s[0]
The next part is to construct a new string from a given one by breaking it at a certain index value, and concatenating the reverse of the second part (the suffix) to the beginning of the first part (the prefix)
For example, if the input string is 'laptop' and the chosen index value is, say, 3, the string is broken as 'lap' + 'top'. 'top' would then be reversed to 'pot' and would be concatenated with the prefix (in the order) as 'pot' + 'lap'
The assignment is somewhat confusing and since I'm a novice with little to no experience besides a couple of days working in Python, I'm a little confused as to what to do. I'm pretty sure I have to use the slice and concatenation operators but I'm not sure how I should go about constructing a function that suits the above criteria. Any pointers?