[Tutor] If then else question

Kent Johnson kent37 at tds.net
Wed Jun 14 20:56:13 CEST 2006


Andrew Robert wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi Everyone,
> 
> In the middle of an if then else, I have the following line
> 
> 	elif ch_val == '040' or ch_val == '011' or ch_val == '012':
> 
> 
> The line works but it is a little ungainly.
> 
> Anyone have a better way of accomplishing the same thing?

elif ch_val in [ '040', '011', '012' ]:

or maybe you like
elif ch_val in '040 011 012'.split():

Kent



More information about the Tutor mailing list