Swift String Exercises: Create a new string without the first and last character of a given string
Write a Swift program to create a new string without the first and last character of a given string. The string length must be at least 2.
Pictorial Presentation:

Sample Solution:
Swift Code:
func without_first_last(_ input: String) -> String {
    var new_str = input.characters
    
    new_str.removeFirst()
    new_str.removeLast()
    
    return String(new_str)
}
print(without_first_last("Hello"))
print(without_first_last("Swift"))
Sample Output:
ell wif 
Go to:
PREV : Write a Swift program  to return the first half of a given string of even length.
NEXT :  Write a Swift program  that accept two strings of different length and return a string of the form short+long+short. Two given string's length may be 0
Swift Programming Code Editor:
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
