I am trying to reverse a string without creating a new string. But this doesnt seem to work. Can anyone tell me why I cannot modify the existing string, esp when a string could be treated as an array of characters?
The following is the code
def reverse(s): for i in range(len(s)/2): t= s[i] s[i] = s[len(s)-1-i] s[len(s)-1-i] = t return s
This is related to the following exercise