What does len mean in python

爱喝马黛茶的安东尼
Release: 2019-06-26 13:46:16
Original
40392 people have browsed it

What does len mean in python

What does len mean in python? Let me give you a detailed introduction:

Function: len()

1. Function:

Return the length of string, list, dictionary, tuple, etc.

2. Syntax:

len(str)

3. Parameters:
str: ​​String, list, dictionary, tuple, etc. to be calculated

related Recommended: "Python Video Tutorial"

4. Return value:

The length of strings, lists, dictionaries, tuples and other elements

5. Example:
5.1. Calculate the length of the string:

>>> s = "hello world php cn"
>>> len(s)
18
Copy after login

5.2. Calculate the number of elements in the list:

>>> l = ['h','e','l','l','o']
>>> len(l)
5
Copy after login

5.3 , Calculate the total length of the dictionary (that is, the total number of key-value pairs):

>>> d = {'num':123,'name':"phpcn"}
>>> len(p)
2
Copy after login

5.4, Calculate the number of tuple elements:

>>> t = ('w','o','r','l','d')
>>> len(t)
5
Copy after login

The above is the detailed content of What does len mean in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!