Мне нужно протестировать много дел, но это решение не очень элегантно:
if '22' in name:
x = 'this'
elif '35' in name:
x = 'that'
elif '2' in name: # this case should be tested *after* the first one
x = 'another'
elif '5' in name:
x = 'one'
# and many other cases
Есть ли способ сделать эту последовательность дел со списком?
L = [['22', 'this'], ['35', 'that'], ['2', 'another'], ['5', 'one']]