how to find the length of a string in python

how to find the length of a string in python

There are many different ways to find the length of a string in python.

The Easiest way to find the length of a string is to use python's built-in function len().


Len() Syntax:

Len(string)

Len() function takes a string as a parameter and returns a type int.


Here is how

returns_length_of_string = len(string)

print(returns_length_of_string)


Another way to find the length of the string is by using python for loop.

length = 0

for i in string:

    length += 1

print(length)


Previous Post Next Post