Closed lucafrance closed 1 year ago
The cmp function has been removed in Python 3.
cmp
I believe the original intention of the exercise is to learn sorting with non-alphabetic orders. The exercise is rephrased to achieve the same result without cmp. A solution would be words.sort(key=len), where words is a list of strings.
words.sort(key=len)
words
The issue has been mentioned here: https://github.com/nltk/nltk_book/pull/261#issuecomment-1412303946
Thanks. Glad to have a replacement question so that external references to the exercises are preserved.
The
cmp
function has been removed in Python 3.I believe the original intention of the exercise is to learn sorting with non-alphabetic orders. The exercise is rephrased to achieve the same result without
cmp
. A solution would bewords.sort(key=len)
, wherewords
is a list of strings.The issue has been mentioned here: https://github.com/nltk/nltk_book/pull/261#issuecomment-1412303946