Swift String Exercises: Create a new string of any length from a given string where the last two characters are swapped
Write a Swift program to create a new string of any length from a given string where the last two characters are swapped, so 'abcde' will be 'abced'.
Pictorial Presentation:

Sample Solution:
Swift Code:
Sample Output:
abced 12354
Swift Programming Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a Swift program to concat two given strings and return the new string. If the new string creates a double character then omit one of the character. so "vwx" and "xyz" will return "vwxyz".
Next: Write a Swift program to return "abc" or "xyz" if a given string begins with "abc" or "xyz" otherwise return the empty string.
What is the difficulty level of this exercise?