Reverse(text) and cheating the system


15.7 Practice Makes Perfect/ reverse function

it behaves correctly

def reverse(text):
    txt = ""
    for x in text:
        txt = text[len(text)::-1]
        return txt
print reverse("abcde")

Hello, I know this post is not significant to the topics, but I was wondering even though my code works perfectly however in the instructions it was stated we should not use the following built in commands reversed and [::-1] but my code worked with [len(x)::-1]. In other words did I pass this lesson fairly or did I cheat this lesson and it requires me to use a different method ?


you did cheat a little bit yes, but you are here to learn, so if you want to cheat, we won't stop you

but i would recommend a different solution, yes :slight_smile:


Alright, thanks for the fast response, I will be trying to figure a different solution after I go through some exercises and will be posting it.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.