<prompt> HabariKuandika algorithm kubadilishana herufi ya kwanza na ya mwisho katika kamba.  <response>: Here is an algorithm to swap the first and last characters in a string:1. Create a function to accept a string as a parameter.2. Get the length of the string.3. Check if the length of the string is less than or equal to 1. If true, return the original string.4. Find the characters: first_char at index 0, and last_char at index n-1, where n is the length of the string.5. Create a new string composed of the last_char followed by all the characters in the middle of the string from index 1 to n-2 and then first_char.6. Return the new string.Here is an example code implementation in Python:pythondef swap_first_and_last_charstring: n lenstring if n 1: return string first_char string0 last_char stringn-1 new_string last_char string1:n-1 first_char return new_string Example: pythonstring helloresult swap_first_and_last_charstringprintresult output: oellh 