RC wrote: > unsortedList = list(["XYZ","ABC"]) > > sortedList = unsortedList.sort() > print sortedList > > > Why this return None?
Because the sort method sorts the list in place (and returns None). > How do I get return as ["ABC", "XYZ"]? >>> unsortedList = ["XYZ","ABC"] >>> unsortedList.sort() >>> unsortedList ['ABC', 'XYZ'] or if you want a distinct sorted list (leaving the original list unchanged) >>> unsortedList = ["XYZ","ABC"] >>> sortedList = sorted(unsortedList) >>> unsortedList ['XYZ', 'ABC'] >>> sortedList ['ABC', 'XYZ'] >>> Duncan -- http://mail.python.org/mailman/listinfo/python-list