Reverse


#1

I don't understand why not!!

def reverse(text):
	a = str(text)
	count = len(a)
	rev_word = ""
	while count == 0:
	    rev_word = rev_word + a[count - 1]
            count = count - 1
            return rev_word

Reverse
#2

a function ends the moment a return keyword is reached, which happens in the first run of your loop, you might want to change the indent of return so your whole loop can run.


#3

Thank you for your answer
I have changed it this way, but it doesn't work again...
'''
def reverse(text):
a = str(text)
count = len(a)
rev_word = ""
while count == 0:
rev_word = rev_word + a[count - 1]
count = count - 1
return rev_word
'''


#4

i said you should change the indent of one line, please use markup to post your code:


#5

def reverse(text):
	a = str(text)
	count = len(a)
	rev_word = ""
	while count == 0:
	    rev_word = rev_word + a[count - 1]
        count = count - 1
    return rev_word

#6


#7

if i look at the code you posted on the forum, the indention looks off indeed. I can't help you with fixing indention, that you have to do


#8

Check your while loop on line 5. Will len(a) ever be equal to 0?


#9

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