Reverse


#1

def reverse(text):
	indexOfText = len(text)- 1
	reversedText = ""
	while indexOfText >= 0:
		reversedText += text[indexOfText]
		indexOfText -= 1
	return reversedText

this is my answer is it good ??


Reverse
#2

am sorry i want to ask what is reversedtext = ""


#3

The string that should be returned as the reverse of the original


#4

If it works, it is at least some version of good. Here is my code, slightly more simplified:

def reverse(text):
    rev = ""
    for lett in text:
        rev = lett + rev
    return rev

Notice, all that it does is take each letter in the > text and add it to the front of a string, thereby reversing the original text.

Good job on working this one out. There is always more than one way to skin the proverbial cat.


#5

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