Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It’s not empty its a space.

lets say you add the following words

"hello" "freind"

Without the spaces it would become "hellofreind"

With the spaces it would be "hello freind"

Of course it also has a space at the begining so im assuming it gets added to another word

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading