Sorting email addresses by domain

Alex Martelli aleaxit at
Sun Nov 14 14:47:44 CET 2004

Peter Murray <pdmurray at> wrote:
> Interesting though that to get the whole sequence reversed, you have to use
> seq[::-1], as if you actually specify the bounds, you would always miss out
> the final item:
> >>> "peter murray"[::-1]
> 'yarrum retep'
> >>> "peter murray"[12:0:-1]
> 'yarrum rete'
> >>> "peter murray"[12:-1:-1]
> ''
> Because the slice is up to and not including the final item.

That's what None is for:

>>> 'peter murray'[12:None:-1]
'yarrum retep'


More information about the Python-list mailing list