String Length in Python

In programming, sometimes, it is very useful to know the length of string. To find out the length of a string in Python, built-in function len() is used.

Following Python program illustrates the use of built-in function len()

Python Source Code: Length of String

string_1 = "Hello, There!"
string_2 = "Welcome to Python string!"
string_3 = "Revolutions are the locomotives of history. - Karl Marx"

print('Length of string_1: ', len(string_1))
print('Length of string_2: ', len(string_2))
print('Length of string_3: ', len(string_3))

Output: String Length

Length of string_1:  13
Length of string_2:  25
Length of string_3:  55