Easy Tutorial
❮ Python Func Number Atan Python List Swap Two Elements ❯

Python String Length Check

Python3 Examples

Given a string, determine its length.

Example 1: Using the built-in method len()

str = "tutorialpro"
print(len(str))

Executing the above code outputs:

6

Example 2: Calculating with a loop

def findLen(str): 
    counter = 0
    while str[counter:]: 
        counter += 1
    return counter 

str = "tutorialpro"
print(findLen(str))

Executing the above code outputs:

6

Python3 Examples

❮ Python Func Number Atan Python List Swap Two Elements ❯