Is there a way to create if else statement like this one?

if 0<x=<0.2 is true, y =1

if 0.2<x=<0.4 is true, y =2

if 0.4<x=<0.4 is true, y =3

if 0.6<x=<0.8 is true, y =4

if 0.8<x=<1.0 is true, y =5

Thank you,

I just decided to use python instead.

Be sure to share your Python solution? Hard to believe it would be simpler than what @akilli posted.

here is the script

if x <= 0.2 and x >= 0:

print (β1β)

if x <= .4 and x > .2:

print (β2β)

if x <= .6 and x > .4:

print (β3β)

if x <= .8 and x > .6:

print (β4β)

if x <= 1 and x > .8:

print (β5β),

then convert it to a number.

```
if x <= 0.2 and x >= 0:
print (β1β)
if x <= .4 and x > .2:
print (β2β)
if x <= .6 and x > .4:
print (β3β)
if x <= .8 and x > .6:
print (β4β)
if x <= 1 and x > .8:
print (β5β)
```

That produces an error:

Runtime error (SyntaxErrorException): unexpected token βββ

File ββ, line 2

print (β1β)

^

SyntaxError: unexpected token βββ

This works better:

```
if x <= 0.2 and x >= 0:
a = 1
if x <= .4 and x > .2:
a = 2
if x <= .6 and x > .4:
a = 3
if x <= .8 and x > .6:
a = 4
if x <= 1 and x > .8:
a = 5
```

Do you understand what @akilli posted? Itβs better than a series of βifβ statements.

## Math

if you don t care about includiung 0 and values below 0 or above 1

you can also use

`y = Ceiling(x/0.2)`

(Ceiling β round up to next integer equal or bigger

Floor β round down β¦)

## title / topic

and as the title of your topic might direct someone with a complete different question:

The Sift+Combine pattern is designed to mimic conditional clauses (i.e. βif statementsβ). It allows you to pull apart a stream of data, operate on subsets of that stream and then put it all back together again in the same order.

from the old forum

`Find Domain` is far more flexible than a series of hand coded βifβ statements:

find domain_2023Feb19a.gh (12.9 KB)

True, I will use that for the future.

Thank you for the help and script it is very much apricated.

Stream filter (or stream gate) worked well for me for a true/false if/then filter.