On Wed, 02 Oct 2013 03:04:16 -0700, subhabangalore wrote: > Dear Group, > > I am trying to work out a solution to the following problem in Python. > > The Problem: > Suppose I have three lists. > Each list is having 10 elements in ascending order. I have to construct > one list having 10 elements which are of the lowest value among these 30 > elements present in the three given lists.
If they have to be the lowest *unique* values, the easiest way is to build a set from all three lists, then sort, and take a slice of only the first 10: sorted(set(alist + blist + clist))[:10] If you don't want unique values, but want to keep duplicates, then drop the call to set: sorted(alist + blist + clist)[:10] > The Solution: > > I tried to address the issue in the following ways: Thank you for posting your attempts to solve this problem! You had the right idea, you just did a little bit too much work. -- Steven -- https://mail.python.org/mailman/listinfo/python-list