String max() and string min() function in python

  • String max() Function in python returns the maximum alphabetical character from the string
  • String min() Function in python returns the minimum alphabetical character from the string

 

Syntax of String max() and String min() Function in Python:

1.max(str)

2.min(str)

str – This is the string from which maximum or minimum alphabetical character needs to be returned.

 

Example of String max() Function in Python

String max() Function in python returns the maximum alphabetical character from the string

#string max() Function example
str = "Salute to the mother earth"
print "Maximum alphabetic character in the string is :"+ max(str)

so the output will be

Maximum alphabetic character in the string is :t

 

Example of String min() Function in Python

String min() Function in python returns the minimum alphabetical character from the string

#string min() Function example
str1 = "salute to the mother earth"
str2 = "salute-to-the-mother-earth!"
str3 = "salutetothemotherearth"

print "Minimum alphabetic character in the string1 is :"+ min(str1)
print "Minimum alphabetic character in the string2 is :"+ min(str2)
print "Minimum alphabetic character in the string3 is :"+ min(str3)
  • First min() function returns the space which is minimum character of that string
  • Second min() function returns the ! symbol which is minimum character of that string
  • Third min() function returns the “a” which is minimum character of that string

So the output will be

Minimum alphabetic character in the string1 is :
Minimum alphabetic character in the string2 is :!
Minimum alphabetic character in the string3 is :a

 

previous String max() and string min() function in python                                                                                                           next String max() and string min() function in python

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts