denismfmcmahon at gmail.com
Sun Jul 19 02:59:18 CEST 2015
On Sat, 18 Jul 2015 12:35:10 +0200, Sibylle Koczian wrote:
> Am 18.07.2015 um 02:40 schrieb Denis McMahon:
>> Having a list of words, get a copy of the list in reverse order. See
>> the reversed function (and maybe the list function).
> That won't really help, because the desired order is, with the example
> the OP used: Sirna Daniel Craig. So here indexing is necessary, but
> indexing of the list elements, not of the characters in the string.
Oh, then it's even easier, yes, it's mainly a case of list indexing.
1) Split the original string into a list of words (string.split() method)
2) create a sublist (s1) of the last element
3) create another sublist (s2) of the first to penultimate elements
4) combine the two sublists
5) use the string.join() method to combine the sublist elements into a
I think most pythonistas would probably combine steps 2 through 4 in a
single line of code, possibly even steps 2 through 5.
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list