Reverse a string

Write a function named reverse_string that takes a string text as input and returns a new string with the characters of text reversed. Use a for loop rather than slicing with [::-1].

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

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


assert reverse_string("Hello, World!") == "!dlroW ,olleH"
assert reverse_string("") == ""
assert reverse_string("12345") == "54321"
assert reverse_string("a") == "a"

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.