I have tried a number of things but I can’t get the thingy to iterate backwards. The program has run out of oops to show me. Some times I get its just “!” when it should be… 'int- instead of… or like in the case below, “Your function fails on reverse(“Python!”). It returns “None” when it should return “!nohtyP”.”
I’m trying to understand.
I think the code below would mean:
—for i in text: #for each index in the string Python!
-------while len(text)>i: #while 7-the length of the string- is larger than the index number
-----------position = len(text) - i # position is equal to the length of text minus the index number
----------- return text[position] #return the letter on index number position
It doesn’t iterate through the string, much less backwards.
The program throws an oops, in this case saying that returns NONE.
I have tried a dozen ways and the closest I get is getting a ‘!’ but not the rest of letters in reverse order.
Could anyone explain, please?
There is, obviously something I fail to understand!!!
Many, many thanks,