Need help with a string plz! (newbie)

israphelr at googlemail.com israphelr at googlemail.com
Fri Mar 9 16:50:47 EST 2007


On Mar 9, 9:37 pm, Grant Edwards <gra... at visi.com> wrote:
> On 2007-03-09, israph... at googlemail.com <israph... at googlemail.com> wrote:
>
> > 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.
>
> s = ''
> for c in word:
>     s = c + s
> print s
>


Okay thanks very much, I used this method, since it's cloest one to I
am already faimilar with.

Here's the final code..(if anyones interested)

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

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

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

end = len(word)
end -= 1
new_string = ""

for position in range(end, -1, -1):
   new_string += word[position]

print new_string

raw_input("\nPress Enter to Exit")

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




More information about the Python-list mailing list