Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
SCIENTIFIC EXPEDITION - "Pangram" solution in Clear category for Pangram by jsg-inet
def check_pangram(text):
'''
is the given text is a pangram.
'''
# From inside to outside:
#
#
# >> text.lower() <<
# To convert all char to lower case.
# Otherwise 'T' and 't' are considered like two diffrent elements.
#
#
# >> {x for x in text.lower() if x.isalpha()} <<
# Then we extract all chars that are in [a-z]
# inside a set (no duplicates values in a set type).
#
#
# >> len({x for x in text.lower() if x.isalpha()}) <<
# Now we obtain the "size" of the set using len()
#
#
# >> return len({x for x in text.lower() if x.isalpha()})==26 <<
# And finally we return the comparison of len() result and number 26
# (the [a-z] set fo char has 26 elemnts)
# if "text" is a pangram, len = 26, if not, len != 26
return len({x for x in text.lower() if x.isalpha()})==26
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert check_pangram("The quick brown fox jumps over the lazy dog."), "brown fox"
assert not check_pangram("ABCDEF"), "ABC"
assert check_pangram("Bored? Craving a pub quiz fix? Why, just come to the Royal Oak!"), "Bored?"
print('If it is done - it is Done. Go Check is NOW!')
July 9, 2021
Comments: