Reverse


#1



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


My code is correct but i was wondering how can I add raw input to that code so that a user could type a word
normally and it will come out in reverse?


def reverse(text):
    key = ""
    index = len(text)
    for i in range(0, index):
        key = key + text[(index - 1) -i]
    return key


#2

you can add a raw_input before your function:

user_input = raw_input("enter a string you want reversed")
def reverse(text):

and then pass user_input as argument in the function call:

    return key
print reverse(user_input)

#3

2 posts were split to a new topic: Reverse


#5

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