Python Program to find a String Length

Write a Python Program to find a String Length with practical examples.

Python Program to find a String Length Example 1

The program finds the string length using the len function.

Please refer String article to understand everything about Strings in Python.

# Python Program to find a String Length

str1 = "Tutorial Gateway"

print("Total Length of a Given String = ", len(str1))

Python string length output

Total Length of a Given String =  16

Python Program to find a String Length Example 2

This python program is the same as the first example. However, this time, we are allowing the user to enter their own string.

# Python Program to find a String Length

str1 = input("Please enter your own String : ")

print("Total Length of a Given String = ", len(str1))
Python Program to find a String Length 2