If you want to write a function in Python that returns different fixed values based on the value of an input index. In other languages you would use a switch, case statement, but Python does not appear to have a switch statement. In this case, the equivalent to switch is dictionary, here is how you can use it:
def f(x):
return {
'a': 1,
'b': 2,
}[x]