Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This is based on how Python evaluates boolean expressions.

    In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). All other values are interpreted as true.

    After evaluating, Python returns the corresponding side of the expression.

    Here is the explanation:

    1. Left side of and: When a == [] (a empty), [] is evaluated as False, so [] is returned.
    2. Right side of and: inside the brackets

    a. Left side of or: list.remove modifies the list in place and then returns always None, which is evaluated to False.
    b. Right side of or: the expression always goes here and returns a

    Edit: you can take a look at my kumite - shorter and easier to understand

    NB: Sorry CW breaks markdown nested list syntax...

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Thank you for commenting your code!

  • Default User Avatar

    Can you please explain?? This is mind blowing!