Reverse error


def reverse(text):
    a = ""
    b = ""
    for i in text:
        a += i
    total = len(a) - 1
    while total >= 0:
        b += a[total],
        total -=1
    return b

Error :Does your reverse function take exactly one argument (a string)? Your code threw a "cannot concatenate 'str' and 'tuple' objects" error.

Replace this line with your code.



b += a[total],

you have a comma (,) at the end of the line, which makes it a tuple (an immutable list), not sure why you want that. i suggest you remove the comma


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