Remove spaces from a string

Write a function named remove_spaces that takes a string text as input and returns a new string with all space characters (" ") removed. Use a for loop.

Remove only the ordinary space character (" "). Preserve tabs, newlines, and all other characters.

Complete the supplied function in Listing 1. Keep its signature and use the checks below it.

Listing 1: Starter function and supplied checks for remove spaces from a string.
def remove_spaces(text: str) -> str:
    # Add code here!
    pass


assert remove_spaces("Hello, World!") == "Hello,World!"
assert remove_spaces("") == ""
assert remove_spaces("Remove spaces") == "Removespaces"
assert remove_spaces("123 45") == "12345"

len(text) returns the number of characters, so len("cat") is 3 and len("") is 0. A for loop over a string visits its characters in order. String indexing starts at 0, so "cat"[0] is "c"; the index must refer to an existing character.

assert condition stops the check with an AssertionError when the condition is false.