Challenge: String With a Zero Space
Complete this hands-on exercise to test your knowledge.
We'll cover the following
Problem statement
You are given a string s
containing whitespace characters at the beginning and/or end.
Write a function trimstr
that takes in the string as input and returns a new string with the leading and trailing whitespace removed. The list of white spaces are \t \r \n \v \f
.
Input
The input is a single string s
consisting of printable ASCII characters.
Output
The function trimstr
should return a new string with the leading and trailing whitespace removed. The function should return an empty string if the input string contains only whitespace characters.
Exercise
Get hands-on with 1400+ tech skills courses.