New Trick: judge an object in a list of tuple
Closed this issue · 0 comments
axiaoxin commented
#! /usr/bin/env python
'''there is a list of tuple, and if you want to judge an object in this list by an elegant way, then...'''
from more_itertools import flatten # pip install more_itertools
types = [('E', 'I'), ('S', 'N'), ('T', 'F'), ('J', 'P')]
if __name__ == '__main__':
assert 'E' in flatten(types)
assert 'X' in flatten(types)