Python-计算列表中的元素 [英] Python - Count elements in list

查看:103
本文介绍了Python-计算列表中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种简单的方法来获取列表中元素的数量:

I am trying to find a simple way of getting a count of the number of elements in a list:

MyList = ["a", "b", "c"]

我想知道此列表中有3个元素.

I want to know there are 3 elements in this list.

推荐答案

len()

>>> someList=[]
>>> print len(someList)
0

这篇关于Python-计算列表中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆