words = [line.strip() for line in open('/usr/share/dict/words') if line.strip()] print([w for w in words if w == w[::-1] and len(w) > 6])