def test(filename):
return not filename.endswith(".dat") and (
filename.endswith(".dat") or not filename.endswith(".cup")
)
for filename in [
"name.txt",
"name.dat",
"name.cup",
]:
print(f"{filename}: {test(filename)}")
ZGVmIHRlc3QoZmlsZW5hbWUpOgoJcmV0dXJuIG5vdCBmaWxlbmFtZS5lbmRzd2l0aCgiLmRhdCIpIGFuZCAoCiAgICAJZmlsZW5hbWUuZW5kc3dpdGgoIi5kYXQiKSBvciBub3QgZmlsZW5hbWUuZW5kc3dpdGgoIi5jdXAiKQoJKQoJCmZvciBmaWxlbmFtZSBpbiBbCgkibmFtZS50eHQiLAoJIm5hbWUuZGF0IiwKCSJuYW1lLmN1cCIsCl06CglwcmludChmIntmaWxlbmFtZX06IHt0ZXN0KGZpbGVuYW1lKX0iKQ==