in reply to Re^2: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
No need for a list comprehensions here. How about this...[word for word in words.split()] ?
def reverseWords(words): return ' '.join(words.split()[::-1])
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
by paddy3118 (Acolyte) on Aug 15, 2007 at 08:40 UTC |
In Section
Meditations