Remove Whitespace from String
Advanced
Description
Welcome to the world of Python string processing!
Strings can be a lot of fun, but sometimes they have unwanted spaces that make them look messy. Your challenge today is to write a function that cleans up a string by removing any extra spaces in it. This includes spaces at the beginning, end, and even in between words.
Here’s your task:
Write a function called remove_whitespace that takes a single string as its input and returns a new string with all the spaces removed.
Examples:
remove_whitespace(" Hello World ")should return'HelloWorld'remove_whitespace(" Coding is fun! ")should return'Codingisfun!'remove_whitespace(" ")should return''
Keep it simple, and remember: no space should survive!
You’ve got this. Happy coding!
Inputs
Arg 1:
" Hello World "Expected Output
"HelloWorld"Actual Output