(a==b) ? 'Yes' : 'No'

Steve Howell showell30 at yahoo.com
Fri Apr 2 16:58:14 CEST 2010


On Apr 2, 7:52 am, Tim Chase <python.l... at tim.thechases.com> wrote:
> Steve Howell wrote:
> > I forgot this one:
>
> > def obfuscated_triager(rolls, pins,
> >         lookup = ['normal'] * 10 + ['strike'] + [None] * 9 + ['spare']
> >         ):
> >     return lookup[rolls * pins]
>
> Bah...no need to be _quite_ so obscure:
>    def triager(rolls, pins):
>      return {
>        (1, 10):'strike',
>        (2,10):'spare',
>        (2,0):'wow, you stink',
>        }.get((rolls, pins), 'normal')
>
> ;-)
>

Well played.






More information about the Python-list mailing list