判断相邻四个坐标格上是否都为“#”或都为“.”,代码如下

def judge(x, y, l):
    if (l[y][x]=='#')&(l[y+1][x+1]=='#')&(l[y+1][x]=='#')&(l[y][x+1]=='#'):
        return True
    elif (l[y][x]=='.')&(l[y+1][x+1]=='.')&(l[y+1][x]=='.')&(l[y][x+1]=='.'):
        return True
    else:
        return False
out = []
T = int(input()) #数据组数
for i in range(T):
    add = False    #思路:坐标编号
    l = []
    for j in range(4):
        l.append(input())
    for y in range(0, 3):
        for x in range(0, 3):
            if judge(x, y, l):
                add = True
                break
        if add:
            break
    if add:
        out.append('Yes')
    else:
        out.append('No')
for i in out:
    print(i)