On 18/01/06, ryan luna <[EMAIL PROTECTED]> wrote:
Oh sorry it probably wasn't clear you need to either directly print ''.join(word) or assign it to a variable which could be something like this: word = ''.join(word) if you want to use the same variable.
--- Adam <[EMAIL PROTECTED]> wrote:
> 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.
>
Great! thanks, but the last part, for some reason, the
last part ''.join() isn't working it stays in list
forms, donno what im doin wrong, heres my code.
print "Enter a word and i well tell you how to say it
backwards"
word = raw_input("Your word: ")
word = list(word)
word.reverse()
''.join(word)
print word
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor