Jun-30-2020, 09:07 PM
Let's say I want to see if the first item in one string is the same first item as the second string in the array. Or, I want to check if the last item of the first string aligns with the last item of the second string in the array. See below of the example.
"[A2], [A8]" would equal True because 'A' and 'A' align. "[B7], [C7]" would equal True because the 7's align.
This ended up being the solution:
"[A2], [A8]" would equal True because 'A' and 'A' align. "[B7], [C7]" would equal True because the 7's align.
This ended up being the solution:
def can_capture(rooks): if rooks[0][0] == rooks[1][0] or rooks[0][1] == rooks[1][1]: return True else return FalseI'm just curious how this code works. It is meant to see if the first item in the first string is the same as the first item in the second string. Likewise, it also checks if the second item in the first string is the same item in the second item in the second string? I'm just curious how this code works. How does it find what I just told you about? Coming up with the solution is one thing, but understanding it is also important.