To remove the leading and trailing white spaces in a string we need to use
the trimmingCharacters(in:) method by passing a whitespacescharacter set
offered by the swift.
Example:
let str =" Oxygen "let trimmedStr = str.trimmingCharacters(in:.whitespaces)print(trimmedStr)