The first thing that comes to my mind:
>>> a = "Jack and Jill went up the hill" >>> [e for n, e in enumerate(a.split()) if n in (0, 2)] ['Jack', 'Jill']
In case you are curious: enumerate generates tuples with a progressive number as the first element and an enumerable iterable element as the second.
EDIT: As @kindall comments said, the final step would be:
>>> user1, user2 = [e for n, e in enumerate(a.split()) if n in (0, 2)] >>> user1 'Jack' >>> user2 'Jill'
but I decided not to complete the task, just to give an example as an example (sorry if this confused someone).
source share