cords = []

for y in range(10):
    for x in range(10):
        cords.append((x, y))

print cords
print cords[11]

user_x=raw_input("X: ")
user_y=raw_input("Y: ")

xy = "("+user_x+", "+user_y+")"
print xy


if xy in cords:
        print "Found Match"


我的问题是,给定1和1或任何其他匹配项时,为什么不打印“ Found Match”?

最佳答案

因为字符串永远不会等于元组。

xy = (int(user_x), int(user_y))

10-07 18:25