Returns just firs (or last symbole)


#1

Mine code works, but it returns just firs (or last symbole), when it should return all the phrase. Look at it, and tell me what is wrong here:
UPD - edited a bit, works like expected, but anyways can`t pass to the next one

def reverse(text):
lst = " "

for i in range(len(text)-1, -1, -1):
    lst += text[i]
return lst

Which gives me:

Oops, try again. Your function fails on reverse("Python!"). It returns " !nohtyP" when it should return "!nohtyP".


Any advise on reverse?
#2

Check the error message carefully. See the extra space? The above definition of lst is the reason. Initialize to the empty string, not a single space.

    lst = ""

#3

So, empty string isn`t a string with whitespace inside, as I undrestand? Anyways, it works now, thx


#4

Correct. Try this in Python:

print bool("")

It should print False.

print bool(" ")

It will print True.