Reverse


#1

in python exercise i have to make a function to reverse a string. I implemented the following code with correct indentation.

def reverse(s):
    l = len(s)
    s1 = ""
    for i in range(l):
         s1 += s[l-i-1],
    return  s1

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

how come tuple is created?


#2

this line:

s1 += s[l-i-1],

what does the , do at the end?


#3

Oh sorry that , is a typo i made while copying the code
It was not there when i tried the code in python


#4

are you sure? with the , it perfectly matches the error message. without , your code works fine (maybe refresh the page)