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
Finding the length of a list in Python
schedule Jul 1, 2022Last updated
tocTable of Contentsexpand_more
We can find the length of a list (i.e. number of elements) by using the
To find the length of list
cars = ['mercedes', 'range rover', 'toyota', 'renault']len(cars)4
An embedded list will only count as one item:
dessert = ['cake', 'cookie', 'cupcake', ['pudding','tea']]len(dessert)4
Join our newsletter for updates on new DS/ML comprehensive guides (spam-free)
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
Enjoy our search
Hit / to insta-search docs and recipes!