How Can We Help?
Introduction:
In this tutorial, we are going to explain how to use Python string max() function with basic syntax and many examples for better understanding.
max() is used to get a maximum value of a string.
Syntax:
max(string_variable_name)
Input Parameters:
- string_variable_name : where string is string variable whose minimum value needs to be found.
Example
alphanum='123abc'
data='WelcomePython'
# maximum value of a string
print('max of alphanum:', max(alphanum))
print('max of data:', max(data))
Output
max of alphanum: c
max of data: y
In the above Example, If comparing values of string variable ‘alphanum’ ,value ‘c’ is the greater than other values due to its ASCII value as 99 so output of max(alphanum) is ‘c’ and for string variable ‘data’, ‘y’ is greater 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 max(data) is 121 which is indicated by ‘y’.
In this tutorial, you have learned how to use python string max() function.
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 String max :
- min(string) : It returns a minimum value of string.
- type(string) : It returns a maximum value of string.
- len(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.