String functionsÂ
So far you have seen string methods. Let's see built-in functions of sequences and what values they would return when the string is passed as an argument. At the beginning of the chapter, we have already discussed the len()
function.
Consider you need to find the minimum character from a given string according to the ASCII value. To handle this situation, you can use the min()
function:
min()
The syntax is given as follows:
min(str1)
The min()
 function returns the min character from string str1
according to the ASCII value:
>>> str1 = "Life should be great rather than long" >>> min(str1) ' ' >>> str2 = "hello!" >>> min(str2) '!' >>>Â
The next method is max()
, which returns the max characters from string str
according to the ASCII value. Let's see some examples:
>>> str1 = "Life should be great rather than long" >>> max(str1) 'u' >>> str2 = "hello!" >>> max(str2) 'o' >>>Â
In many situations...