How is this working? It checks if a string contains each character from a-z at least once?
import string
def ispangram(str1, alphabet=string.ascii_lowercase):
alphaset = set(alphabet)
return alphaset <= set(str1.lower())
This returns True for example:
ispangram("The quick brown fox jumps over the lazy dog")
I can only assume it is something to do with lexographical ordering as stated here, but still a bit confused.
Comparing two lists using the greater than or less than operator
When I read the link in this SO question:
https://docs.python.org/3/tutorial/datastructures.html#comparing-sequences-and-other-types
It says:
Sequence objects may be compared to other objects with the same sequence type. The comparison uses lexicographical ordering: first the first two items are compared, and if they differ this determines the outcome of the comparison; if they are equal, the next two items are compared, and so on, until either sequence is exhausted. If two items to be compared are themselves sequences of the same type, the lexicographical comparison is carried out recursively. If all items of two sequences compare equal, the sequences are considered equal. If one sequence is an initial sub-sequence of the other, the shorter sequence is the smaller (lesser) one. Lexicographical ordering for strings uses the Unicode code point number to order individual characters. Some examples of comparisons between sequences of the same type.
But this isn't clear to me.