directory

  • An introduction to the Len function in Python
  • The len function is used in Python
  • Guess you like it

Recommended path for learning Python: Python Learning Directory >> Python Basics

After print, len and type are probably the most frequently used apis in Python.

An introduction to the Len function in Python

The length (item number) argument to return an object can be a sequence (e.g., string STR **, tuple tuple, list list) or a set (e.g., dict**, set, or frozenset frozenset) with the following syntax:

Parameter: s - Object or sequence (such as string STR, tuple tuple, list list) or set (such as dictionary dict, set set, or frozen set) Return value: Return length (>=0) len(s)Copy the code

The len function is used in Python

#! Usr /bin/env python # -* -coding :utf-8 _*- "" www.codersrc.com @file :Python len function. py @time :2021/04/29 07:37 @motto: A thousand miles without a small step, a river without a small stream, the wonderful life of the program needs to be accumulated unrelentingly! "" "a = (# 6) tuple list b = [1, 2, 3, 4] # c = range (0, 10) # range d = {' name ':' lisi ', 'age: 14} # dictionary e =' helloworld ' # # string f = {1, 2, 3, 4, 5} collection g = frozenset freezing (,2,3,4,5,8 [1]) # set print (" a: ", len) (a) print (" b: ", len (b)) print (" c: ", len (c)) Print (" d: ", len (d)) print (" e: ", len (e)) print (" f: ", len (f)), ' ' 'output: a: b: 4 c: d: 2 e: 10 f: 5' ' 'Copy the code

3.Guess you like

  1. The Python for loop
  2. The Python string
  3. The Python list
  4. The Python tuple tuple
  5. Python dictionary dict
  6. Python conditional derivations
  7. Python list derivations
  8. Python dictionary derivations
  9. Python function declarations and calls
  10. Python variable argument *argc/**kargcs
  11. Python anonymous function lambda
  12. Python return logic determines expressions
  13. Python string/list/tuple/dictionary conversions
  14. Python local and global variables
  15. The Python type function is different from the isinstance function
  16. Python is differs from ==
  17. Python mutable and immutable data types
  18. Shallow and deep copies of Python

Len functions in Python

This article is published by the blog – Ape Say Programming Ape Say programming!