Reverse of String


#1

def reverse(text):
    x=len(text)
    for y in range(x):
        a=text[y]
        text[y]=text[x-1-y]
        text[x-y]=a
       
        
    return text   
    print text
reverse(raw_input("Enter something:"))

What is wrong with my code ?


#2

in python strings are immutable. If you want to do this, convert the string into a list.


#3

Worked using list , thanks a lot :slight_smile:


#4