greenflame <[EMAIL PROTECTED]>:
> Roberto: I do not understand the first half of the last line of your
> code.

[mainlist[i - 1] for i in orderinglist] is a list made with the
elements of orderinglist, but instead of taking the actual value i
from the list, the value that is taken is mainlist[i - 1].

If orderinglist is [3, 4, 2, 1], then [mainlist[i - 1] for i in
orderinglist] is:

    [mainlist[3 - 1], mainlist[4 - 1], mainlist[2 - 1], mainlist[1 - 1]]

Remember that indexing starts from 0.
-- 
Roberto Bonvallet
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to