[EMAIL PROTECTED] wrote:
> If what you want is a reversed copy, you could just append list1
> elements to list2, and use the reverse function such as
> >>> ...
> >>> for i in list1:
> ...   list2.append(i)
> ...
> >>> list2.reverse()
> >>> list1
> ['1', '2', '3', '4', '5', '6', '7', '8', '9']
> >>> list2
> ['9', '8', '7', '6', '5', '4', '3', '2', '1']

It's much clearer and simpler to just do:
>>> list2 = list1[:]
>>> list2.reverse()
This saves all the messing around with append, and has the advantage
that it runs faster (by a factor of 30, on my computer).

-- David

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to