Reverse- Print Question


#1

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

I'm a bit confused because my code has passed the section, but I'm struggling to get the reversed result to print onto the console. I'd appreciate any explanation


text = raw_input("Enter a word: ") 
def reverse(text): #function
    x = len(text) #length of string
    result=[]
    for char in str(text):
       result.append(text[x - 1]) 
       x -= 1
    return "".join(result)
    return result
    print result


#2

a function ends the moment a return keyword is reached

a function only executes when called

add a function call, place print before the function call to print what the function returns


#3

text = raw_input("Enter a word: ")
def reverse(text): #function
x = len(text) #length of string
result=[]
for char in str(text):
result.append(text[x - 1])
x -= 1
print result
return "".join(result)
return result
reverse(text)

that should do the trick


#4

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