Need help with a string plz! (newbie)

israphelr at googlemail.com israphelr at googlemail.com
Fri Mar 9 22:25:20 CET 2007


Hi all

So I created a program, that gets a string from a user and then prints
the string in reverse order.

Now, here's the code;

#################################
print "\nWelcome !"
print "\nEnter a word, and the world will be reversed!"

word = raw_input("\nPlease Enter a word: ")

end = len(word)
end -= 1

for position in range(end, -1, -1):
   print word[position],

raw_input("\nPress Enter to Exit")

################################

What actually happens is, the next character is printed on the same
line but, there is a space inbetween each character.

I thought maybe I could create another variable and then assign each
character into the new string by concatenating, makign a new string
each time, but I find this a bit muddling at the moment. Any help'd be
great. Thanks.




More information about the Python-list mailing list