Hi there everyone,
Does anyone have a clue on an ideal function body for this script so that it will pass the doctest?
def sortstuff(mylist): """ >>> sortstuff([3, 5, 1, 9, 13, 2]) [1, 2, 3, 5, 9, 13] >>> sortstuff(["one", "two", "three", "four"]) ['four', 'one', 'three', 'two'] """ # Function body will go here if __name__ == '__main__': import doctest doctest.testmod(verbose=True)
Cheers!
2 years 1 week ago
Should you not use Python sort? For example:
Note that sort is a method, and the list is changed in place.
Suppose you have a matrix, and you want to sort by second column. Example Solution: