KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a .py file that takes a list, finds the lowest number, puts it into a new array, removes the lowest number from the first array, and repeats until the original array returns contains no more items: def qSort(lsort): listlength = len(lsort) sortedlist = list() if listlength == 0: return lsort else: while listlength > 0: lmin = min(lsort) sortedlist.append(lmin) lsort.remove(lmin) listlength = len(lsort) return sortedlist Now another .py file imports the qSort and runs it on some list, saving it to a variable. Then I try to use the .reverse() command on the list and I end up getting it as a NoneType . I try to use reversed() , but all it does is say "<listreverseiterator object at 0xSomeRandomHex>" : from qSort import qSort #refer to my first Pastebin qSort = qSort([5,42,66,1,24,5234,62]) print qSort #this prints the sorted list print type(qSort) #this prints <type 'list'> print qSort.reverse() #this prints None print reversed(qSort) #this prints "<listreverseiterator object at 0xSomeRandomHex>" Can anyone explain why I can't seem to reverse the list, no matter what I do?
Tags (comma-separated)
Save Edits
Cancel