what is the purpose of return_string = " " in the code below. Additionally what is happening in line 4 when " " is added to str(x)

Question:

def even_numbers(maximum):
    return_string = " "
    for x in range(2, maximum+1, 2):
        return_string += str(x) + " "
    return return_string.strip()

Hi i recently started learning how to code and i dont understand equating empty quotation marks and in some codes adding empty quotation marks to strings like in line 4

Asked By: AshaharParvez

||

Answers:

It’s not empty, it’s a space.

Let’s say you add the following words:

"hello" "friend"

Without the spaces it would become "hellofriend".

With the spaces it would be "hello friend".

Answered By: Adam Katz
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.