You don't need [word for word in ...]. That's just the same as map { $_ } ... in perl, an identity op on lists (more or less).
>>> def reverseWords(words): ... return ' '.join(words.split()[::-1]) ... >>> reverseWords(" one two three four ") 'four three two one'
In reply to Re^3: Five Ways to Reverse a String of Words (C#, Perl 5, Perl6, Ruby, Haskell)
by ambrus
in thread Five Ways to Reverse a String of Words (C#, Perl 5, Perl 6, Ruby, Haskell)
by eyepopslikeamosquito
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |