[Tutor] Hmm...I should be able to figure this out...but...

Dragonfirebane at aol.com Dragonfirebane at aol.com
Tue Jul 20 22:54:23 CEST 2004


># Initialize Variables
>string = ""
>stringlength = 0
>
># Begin Program
>
>string = raw_input("Enter a string and I will display it backwards.\n")
>stringlength = len(string)
>
>for i in range (stringlength, 0, -1):
>     print string [i - 1],
>
>print "\n"
>
>raw_input("\nPress the enter key to exit")

try (untested):

# Initialize Variables
string = ""
stringlength = 0
rstring = []

# Begin Program

string = raw_input("Enter a string and I will display it backwards.\n")
stringlength = len(string)

for i in range (stringlength, 0, -1):
     rstring.append(string[i - 1])
     print ''.join(rstring),

print "\n"

raw_input("\nPress the enter key to exit")



-- 
"n thats the way the cookie crumbles"

America's Favorite Cookie



More information about the Tutor mailing list