Reverse - almost but not quite


#1



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


I've managed to come up with code that does the work but not quite as expected. Any suggestions as to how to fix it will be most welcome


wrd = raw_input("Enter a word: ")
def reverse(wrd):
    
    x = len(wrd) # determine the lenght of the string
    
    for i in str(wrd):
        print wrd[x - 1], # print the index position x-1 in every loop
        x -= 1 # diminish x by 1 with every loop
        
reverse(wrd) # for raw-input Python prints n o h t y PNone


#2

Problem: your function needs to return the reversed string. You currently print the reversed string

You are pretty close to printing the reversed string, you need a little more work to make your function capable of returning the reversed string


#3

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