Is the line a pangram?



  • It is necessary to check whether the line is a pangram, that is, if all the alphabet letters are in the line.

    And I decided that:

    def is_pangram(s):
        return set('abcdefghijklmnopqrstuvwxyz') == set(s.lower().replace(' ', ''))
    

    text = input()

    print(is_pangram(text))

    But I found a similar solution:

    def is_pangram(s):
    return not set('abcdefghijklmnopqrstuvwxyz') - set(s.lower())

    text = input()

    print(is_pangram(text))

    I can't understand two things:

    1. Why do you read one lot of other things?
    2. why by adding a logical operator not returning the bulb value



  • Why is one of the many other things going through the sign?

    When we're reading a lot. B of A only those elements from multiple groups remain in a multiplicity of Awhich do not meet many B

    Many A The symbol is missing, so it cannot be produced.


    Why does a logical operator not reset the bulb?

    In [163]: not set()
    Out[163]: True
    

    interpreted as:

    In [165]: not bool(set())
    Out[165]: False
    

    This is what happens when verifying the result.

    PS https://snarky.ca/unravelling-not-in-python/ I can read more about how it works. not <expression> Total Python and how this is done in the reference code Python


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2