Flexible multiple string comparision to determine variable value I've a web form that allows users to create clusters of three sizes: small, medium and large. The form is sending a string of small, medium or large to a message queue, were job dispatcher determines how many jobs (cluster elements) it should build for a given cluster, like that:

# determine required cluster size
if cluster['size'] == 'small':
    jobs = 3
elif cluster['size'] == 'medium':
    jobs = 5
elif cluster['size'] == 'large':
    jobs = 8
else:
    raise ConfigError()


While it works, its very ugly and non flexible way of doing it - in case I'd want to have more gradual sizes, I'd increase number of elif's. I could send a number instead of string straight from the form, but I dont want to place the application logic in the web app. Is there a nicer and more flexible way of doing something like that?
You could keep an array of jobs, and the web application would send index instead of word 'small', 'medium', 'large'.

So you could have an array [3, 5, 8] and instead of "small" you send 0, instead of "medium" you send 1, and instead of "large" you send 2. You only need to check if the index received does not exceed the table size.