Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Built-in Functions Common to Most Data Structures
4. min() and max() – strings
Summary

Instruction

Well done! The min() and max() functions can also be used with strings (when the letters are sorted in alphabetical order) – they return the first (min) or last (max) letter from the string. How does it work? Take a look:

first_name = 'Alasdair'
min(first_name)

In this case, min(first_name) returns the letter 'A'. Note that 'A' comes before 'a' – uppercase letters come before lowercase letters when Python sorts them. That's because each letter (in each case – lower or upper) has its unique number an ASCII code. 'A' corresponds to 65, and 'a' to 97. Hence, 'A' comes before 'a'.

Exercise

Write a function named is_min_identical(string1, string2) that accepts two strings and returns True if both of them have the same "minimum character" (first character alphabetically) and False otherwise.

E.g., for string1 = "first", string2 = "second", the function should return False because the minimum character of string1 is 'f' while the minimum character of string2 is 'c'.

Stuck? Here's a hint!

Simply return the following:

min(string1) == min(string2)