y=if x>High: 2 elif x<Low: 1 else: 0

Pearu Peterson pearu at cens.ioc.ee
Wed May 22 17:56:49 EDT 2002


On 22 May 2002, gr wrote:

> Hi,
> is there a simple possiblity to "teach" Python:
> 
> y=if x>High: 2 elif x<Low: 1 else: 0

Try

  y = (x>High)*2 or (x<Low)

Pearu






More information about the Python-list mailing list