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


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096


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


def reverse(text):
    placeholder = ""   
    for item in text:
        placeholder = item+placeholder
    print (placeholder)


Help.. need explanation for the given code
#2

Hi, @jkm345 ,

Your function does not return the result; it merely prints it.


#3

def reverse(text):
    placeholder = ""   
    for item in text:
        placeholder = item+placeholder
        #print (placeholder)
    return placeholder

#4

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