Python

Python Menu

Python

Python len() Function - Definition, Syntax, Parameters, Examples

Definition

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.

Syntax

len(object)

Parameters

Parameter Description
object Required. An object. Must be a sequence or a collection

Examples

fruits = ["apple", "orange", "mango"] xfruits = len(fruits) print(xfruits) myString = "Amsterdam" xString = len(myString) print(xString)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods