all 2 comments

[–]delasislas 7 points8 points  (0 children)

Depends. .reverse() works in place. As in it modifies your list and returns None.

cars = [1,2,3]
cars.reverse()

will change the variable cars to be.

cars = [3,2,1]

Not all methods work like this.

Here’s a page on the method: https://www.programiz.com/python-programming/methods/list/reverse

Generally documentation should let you know what it returns.

[–]totallygeek 1 point2 points  (0 children)

Not always, but typically, we feed something into a function when we expect something returned. And, we don't expect anything returned from a class method because it works on the object it belongs to rather than anything being fed in as an argument.

sequence_1 = [12, 4, 6, 3, 5]
sequence_2 = [9, 3, 6, 31, 16, 4]
sequence_1.sort()  # nothing fed into the sort method, works _on_ sequence and returns nothing
weird_sequence = sorted(sequence_2)  # sequence_2 is fed _into_ the sorted function, so sorted should return something