How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python string length function with basic syntax and many examples for better understanding.
Python string length / len() function is used to calculate the length of string, len () function is used. It returns a total length of string value, which is equal to the number of characters in the string.
Syntax:
len(string_variable_name)
Input Parameters:
- string_variable_name : the string name which need to get the length of element inside.
Example
alphabet='abcdef'
# length of string
print('length of string:',len(alphabet))
Output
length of string: 6
In the above Example, string variable ‘alphabet’ has six characters so its length is 6 which we got by len(alphabet), so output is “6”.
In this tutorial, you have learned how to get the length or size of string in Python.
Hopefully, it was clear and concise.
If you have a inquiry or doubt don’t hesitate to leave them in comment. we are waiting your feedback as well.
Similar Functions to Python String Length:
- min(string) : It returns a minimum value of string.
- max(string) : It returns a maximum value of string.
- type(string) : It returns type of string , if passed variable is string.
- str(seq) : It converts a sequence/string into string.
- del(string) : It deletes whole string or individual string element or all elements of string.
Related Articles
Python String – Mastering By Practical Examples (Comprehensive Guide)
Python Tutorials List:
- Python tutorials list : access all python tutorials.