How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python string min() function with basic syntax and many examples for better understanding.
Python string min() function is used to minimum character value of a string.
Syntax:
min(string_variable_name)
Input Parameters:
- string_variable_name : where string is a list variable whose minimum value needs to be found.
Example
alphanum='123abc'
data='WelcomePython'
# minimum value of a string
print('min of alphanum:', min(alphanum))
print('min of data:', min(data))
Output
min of alphanum: 1
min of data: P
As per the comparison of alphanumeric, the 0-9 is less than A-Z and A-Z is less than a-z due to ASCII value of them as 0-9 is 0-9, A-Z is 65-90 and a-z is 97-122.
So according to this in the above Example, If comparing values of string variable ‘alphanum’ ,value ‘1’ is the smaller than other values so output of min(alphanum) is ‘1’ and for string variable ‘data’, ‘P’ is smaller than others because ASCII value of ‘P’ is 80 and ‘y’ is 121 and all other alphabet’s ASCII values is present in between these two characters so output of min(data) is 80 which is indicated by ‘P’.
In this tutorial, you have learned how to use python string min() function by giving a practical example.
If you have an inquiry or doubt don’t hesitate to leave them in comment. we are waiting your feedback.But remember to understand the concept very well, you need to practice more.
Hopefully, it was clear and concise.
Similar Functions to Python List Type:
- max(string) : It returns a minimum value of a list.
- type(string) : It returns a maximum value of a list.
- len(string) : It returns type of list , if passed variable is a list.
- str(seq) : It converts a sequence/string into a list.
- del(string) : It deletes whole list or individual list element or all element of a list.
Related Articles
Python String – Mastering By Practical Examples (Comprehensive Guide)
Python Tutorials List:
- Python tutorials list : access all python tutorials.