On 18/01/06, ryan luna <[EMAIL PROTECTED] > wrote:
Hello, what i need to do is get user input and then
print the string backwards ^^ i have no idea how to do
that,

print "Enter a word and i well tell you how to say it
backwards"

word = raw_input("Your word: ")

print word

all that is simple enough im sure printing it out
backwards is to, just dont know how ^^, thanks for any help.

How's this for you?

>>> l = list('string')
>>> l
['s', 't', 'r', 'i', 'n', 'g']
>>> l.reverse()
>>> l
['g', 'n', 'i', 'r', 't', 's']
>>> ''.join(l)
'gnirts'

As you can see I converted the string to a list using the list() function and then applied the reverse method of the list to put it the other way round and finally used the string method join() to change it back to a string.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to