python获取列表长度
Posted CaoDavidgogo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python获取列表长度相关的知识,希望对你有一定的参考价值。
Get list length in Python 3 | Examples |
len() function | list = [10, 20, 30] n = len(list) print(“The length of list is: “, n) |
for loop | list = [‘Python’,’Java’,’Kotlin’,’Machine Learning’,’Keras’] size = 0 print(“Length of the input string:”) for x in list: size+=1 print(size) |
len() function for nested list | nestedList = [‘Krishna’, 20,’John’, [20, 40, 50, 65, 22], ‘Yung’, 11.98] print(“Original List = “, nestedList) print(“Length of a Nested List = “, len(nestedList[3])) |
how to get the list length in python
以上是关于python获取列表长度的主要内容,如果未能解决你的问题,请参考以下文章