chevron_left
Cookbooks
Accessing an item in a listAdding items to a listChecking if a list is emptyChecking whether a value is in a listConcatenating two listsCopying a list in PythonDifference between append and extend methodsDifference between sort and sortedFinding the index of an element in a listFinding the length of a listIterating from index oneLooping through listsModifying listsPrinting a list in reverse orderRemoving items from a listSorting a listUsing enumerate and zip at the same time
0
0
0
new
Printing a list in reverse order in Python
Programming
chevron_rightPython
chevron_rightOperations
chevron_rightList Operations
chevron_rightCookbooks
schedule Jul 1, 2022
Last updated Python
Tags tocTable of Contents
expand_more We can reverse the order of a list in Python by using the list.reverse()
method.
animals = ['cat', 'doge', 'bird']animals.reverse()print(animals)
['bird', 'doge', 'cat']
Note that the list.reverse()
method simply reverses the order of the list, it does not sort backward alphabetically. This is a permanent change to the order of the original list.
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
Ask a question or leave a feedback...
0
0
0
Enjoy our search