To build a Length calculator in Python, we need to use len() function and len() function In Python, used to calculate the length of a string (object). It takes in a single argument, which can be any object that has a defined length, for example:- string, list, tuple, or array.
Please note: If you want only the final code please jump to the Final complete code see below table of contents.
Step 1 Create input
input("Please Enter Your Contain:")
Step 2 use len() outside input()
len(input("Please Enter Your Contain:"))
Step 3 Create a Variable for storing len data
num_char = len(input("Please Enter Your Contain:"))
Step 4 Convert integer in a string to print out-put with string letter
str(num_char)
Step 5 Using print() print output
print("Your Contain Has " + str(num_char) +" Character Lenths.")
Final Code
#Lenth Calculator
num_char = len(input("Please Enter Your Contain:"))
print("Your Contain Has " + str(num_char) +" Character Lenths.")
Length Calculator Final Output
┌──(kali㉿kali)-[~/python/webproject/error]
└─$ python3 main.py
Please Enter Your Contain:Amol
Your Contain Has 4 Character Lenths.
What is len function in python?
len() function is a built-In Python function, used to calculate the length of a string (object). It takes in a single argument, which can be any object that has a defined length, for example:- string, list, tuple, or array.
How to calculate the length of a string in pthon?
To calculate the length of a string in Python, we need to use the len() function, for example, print(len(“amol”)) and output 4. For more clarification please see the above example.
For more information visit on our YouTube Channel.

