Whats wrong in this one



'str' object does not support item assignment

return the reverse

def reverse(text):
    for i in range(len(text)):
    return text2




strings are immutable, they don't support item assignment like you are trying. For this to work, text2 should be a list (lists are mutable and do support item assignment)


so, how do i accomplish the same using a list?


isn't it in my answer?

all you need to do is change text2 from string to list

if you need more help, post an updated version of your code


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