def reverse2(text): x=len(text)-1 f="" for i in text: f+=text[x] x-=1 print f print reverse2("Why isn't this working?")
Why doesn't my above code work? I've run it and the results are the same as the following code, neonhight's code:
def reverse(text): rev_text =  final = "" for char in text: rev_text.append(char) dummy = list(rev_text) for letter in dummy: final += rev_text.pop() return final print reverse("Why is this working?")
It's probably something simple I'm missing but I'd still like to know what I'm doing wrong.