def reverse(text): length = len(text) - 1 new = " " for i in range(length, 0): new = new + text[i] return new
this was my code in 7/15 reverse. but the code only returns " ". i dont understand why it doesnt concatenate the last letter of the string(represented by the variable length) to " ".
i am assuming that in the for loop, range function cannot generate numbers in decreasing order because this code perfectly works with while loop.
can anyone confirm this? or is there another bug in the code?