white_ranges = [('0', '9'), ('A', 'Z'), ('a', 'z')] any([ord(low) <= ord(x) <= ord(high) for low, high in white_ranges])