Ad
  • Default User Avatar
  • Default User Avatar
  • Default User Avatar

    In python, conditional and Boolean expressions contain empty objects(0, None, ", [], {} ...) are treated as False, not empty(1, [1, 2] , {34, 45}, ' qwerty', print, int) as True. But it is important to remember that they are not equal! That is, 1 == True, but 1 is not True. For example: if 3+5: print('hi') here 3+5 is not an empty object that is perceived as True in the context of a conditional expression. But at the same time (3 + 5 ) != True.
    Now about the main thing. Logical operations in python use so-called Lazy Evaluation. This means that in an expression for example: (False and True) values are calculated in order from left to right, but and gives True only if both(all) operands are True, that is, as soon as python gets False in an expression with AND, it knows that the truth will not work and immediately returns this value. An expression with OR gives True if at least one operand is True, that is, it will return the first one that comes along, but if it does not find it, it will return the last one.
    Here I hope I pushed you on the right path and didn 't confuse you too much : D

  • Default User Avatar

    "a or b" <=> "a if a else b"

  • Default User Avatar

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

  • Default User Avatar

    I'm new to coding. How do you know the for loop goes through both lists? Is there a default? When you leave the first i in the if statement unspecified, is it looping through both?