python - Functions with strings -
i working pyhton on codecademy , stucked in 1 part. goal this: "define function called reverse takes string 'text' , returns string in reverse. may not use reversed or [::-1] this." did 1 , not working this:
t = raw_input("enter: ") def reverse(t): x = [] in range(len(t)): x.append(t[len(t) - - 1]) print ''.join(x)
but when working.
t = raw_input("enter: ") x = [] in range(len(t)): x.append(t[len(t) - - 1]) print ''.join(x)
what wrong first one?
the first not work because, you're not calling reverse
function on t
.
def reverse(t): x = [] in range(len(t)): x.append(t[len(t)-a-1]) return ''.join(x) t = raw_input("enter: ") print(reverse(t))
in example you're obtaining input, doing nothing it.
Comments
Post a Comment