in reply to Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
I didn't want Python to feel left out:
It has been a long time since I hacked python, so I am sure there is a better way to do this, but then again, there might only be one way ;)def reverseWords (s): l = s.split(" ") l.reverse() return " ".join(filter(lambda x: x != '', l))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
by webfiend (Vicar) on Dec 12, 2006 at 17:46 UTC | |
by ambrus (Abbot) on Dec 12, 2006 at 22:03 UTC | |
by Anonymous Monk on Jun 05, 2007 at 13:41 UTC | |
by paddy3118 (Acolyte) on Aug 15, 2007 at 08:40 UTC |