Mar-18-2024, 07:57 PM
(This post was last modified: Mar-18-2024, 07:57 PM by deanhystad.)
In this code:
You can fix this by printing articles_upvotes like this:
print(articles_upvotes.sort())sort changes the order of objects in articles_upvotes and returns None. The print command does not print articles_upvotes, it prints the value returned by articles_upvotes.sort().
You can fix this by printing articles_upvotes like this:
articles_upvotes.sort() print(articles_upvotes)Or you can use sorted that returns a sorted copy of articles_upvotes. articles_upvotes is unchanged.
print(sorted(articles_upvotes))All functions return a value. Often the returned value is None. You should read the documentation and look to see what value is returned. If the return value isn't mentioned, it is probably None.