To find length of any string in python, you have to ask from user to enter any string and then find the length of that string using the len() function as shown in the program given below.
Following python program ask from user to enter a string and find the length of that string:
# Python Program - Find Length of String print("Enter 'x' for exit.") string = input("Enter a string to find its length: ") if string == 'x': exit(); else: print("\nLength of the string =", len(string))
Here is the sample run of the above Python program:
Now enter any string say codescracker and press enter key to find its length or to find entered string's length as shown here:
Same program on python shell:
Program Video with Compile and Run
You may also like to learn or practice the same program in other popular programming languages: