FAQ: Learn Python - Practice Makes Perfect - reverse

As shown in staffsar’s response, in the solution, it first converted

l = len(text) - 1
while l >= 0:
word = word + text[l]
l -= 1

In my solution, I tried to use

while len(text) >= 1:
word = word + text[len(text) - 1]
len(text) = len(text) - 1

but I get “SyntaxError: can’t assign to function call”

My question is: why doesn’t len(text) = len(text) - 1 work?

Pretty much says it all. If we wish to add to length, then we must add to the list. The len() function evaluates the length of list and returns a value. Something that returns a value cannot be assigned to, but assigned to something.