About 31,000 results
Open links in new tab
  1. Python len() Function - W3Schools

    The len() function returns the number of items in an object. When the object is a string, the len() function returns the number of characters in the string.

  2. Using the len() Function in Python

    Nov 16, 2024 · The len() function in Python is a powerful and efficient tool used to determine the number of items in objects, such as sequences or collections. You can use len() with various data types, including strings, lists, dictionaries, and third …

  3. Python len() Function - GeeksforGeeks

    Apr 15, 2025 · The len() function in Python is used to get the number of items in an object. It is most commonly used with strings, lists, tuples, dictionaries and other iterable or container types. It returns an integer value representing the length or the number of elements. Example: Python

  4. Python len()

    The following example shows how to use the len() function to get the length of a string, the number of elements in a tuple, and the number of items in a range: s = 'Python' print(len(s)) # 👉 6 seasons = ('Spring', 'Summer', 'Autumn', 'Winter') print(len(seasons)) # 👉 4 r = range(1, 10) print(len(r)) # 👉 9 Code language: Python (python ...

  5. What is len() in Python? How to Use the len() Function to Find …

    Feb 24, 2022 · When you use the len() function to get the length of a string, it returns the number of characters in the string – including the spaces. Here are 3 examples to show you how it works: name = "freeCodeCamp" print(len(name)) # Output: 12

  6. Python len() Function - Programiz

    The len() function returns the length (the number of items) of an object. Example languages = ['Python', 'Java', 'JavaScript'] length = len(languages) print(length) # Output: 3

  7. Len () Function in Python - pybeginners.com

    Jan 5, 2025 · How do we use the Len () function? Let us learn how to use the len() function with the help of some examples. text = "Hello, World!" length = len(text) print (length) # Output: 13. In this example, len(text) returns 13, as there are 13 characters in the string "Hello, World!".

  8. Understanding `len()` in Python: A Comprehensive Guide

    Mar 22, 2025 · What is len() in Python? The len() function in Python is used to calculate the length of an object. In Python, many data structures such as strings, lists, tuples, sets, and dictionaries have a concept of length. The len() function returns an integer value representing the number of items in the given object.

  9. Python len() Function: How to find length of the string - Guru99

    Aug 12, 2024 · len () is a built-in function in python. You can use the len () to get the length of the given string, array, list, tuple, dictionary, etc. Value: the given value you want the length of. Return value a return an integer value i.e. the length of the given string, or array, or list, or collections. len () is a built-in function in python.

  10. Understanding List Length in Python with `len ()`

    Aug 26, 2024 · Simply put, len () is a built-in Python function that calculates the number of items (elements) within a sequence like a list, tuple, string, or other similar data structures. Think of it as a measuring tape for your Python containers. It tells you exactly how many things are inside! Why is len () Important?

  11. Some results have been removed