What am i doing wrong?


#1

def reverse(text):
    length = len(text)
    while length != 0:
        return text[length]
        length = length-1
        
print reverse("nidhi")

#2

a function ends the moment a return keyword is reached

so you want to create a list/string (you choice) before loop to which append/add the letters


#3

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