How to check variable against 2 possible values?

Solution 1:

if s in ('a', 'b'):
    return 1
elif s in ('c', 'd'):
    return 2
else:
    return 3

Solution 2:

 d = {'a':1, 'b':1, 'c':2, 'd':2}
 return d.get(s, 3)

Solution 3:

If you only return fixed values, a dictionary is probably the best approach.

Solution 4:

if s in 'ab':
    return 1
elif s in 'cd':
    return 2
else:
    return 3

Solution 5:

return 1 if (x in 'ab') else 2 if (x in 'cd') else 3