I want to convert the script threshold for MNDVI from Google Earth Engine (JavaScript) to Jupyter (Python).

In this case, we make the threshold to 4 class MNDVI and the result is one layer, like this

```
mndvi_images = ee.ImageCollection.fromImages([
    calculate_mndvi(year)
    for year in yearlist
])

print(mndvi_images.getInfo())

#CREATE VEGETATION CLASS

  threshold1 = mndvi_images.select('MNDVI').gt(-1).And(mndvi_images.select('MNDVI').lt(0.2)).selfMask()
  threshold2 = mndvi_images.select('MNDVI').gt(0.2).And(mndvi_images.select('MNDVI').lt(0.4)).selfMask().multiply(2)
  threshold3 = mndvi_images.select('MNDVI').gt(0.4).And(mndvi_images.select('MNDVI').lt(0.6)).selfMask().multiply(3)
  threshold4 = mndvi_images.select('MNDVI').gt(0.6).And(mndvi_images.select('MNDVI').lt(1)).selfMask().multiply(4)

  threshold1 = threshold1.toShort().select(0).rename('MNDVI')
  threshold2 = threshold2.toShort().select(0).rename('MNDVI')
  threshold3 = threshold3.toShort().select(0).rename('MNDVI')
  threshold4 = threshold4.toShort().select(0).rename('MNDVI')

# STACKING LAYER
stacking_layer = ee.ImageCollection.fromImages([threshold1, threshold2, threshold3, threshold4])
print(stacking_layer,'staking'+i)
# Mosaic the ImageCollection.
stacking = stacking_layer.mosaic()
Map.addLayer(stacking, {'palette': ['e81410',  'f0fc0a',  '30bf21', '198f0d'], 'min':1, 'max':4},'Vegetation'+i)

```

But, when I run in jupyter python, there's an error like this:

> 
> Input In [6]
> threshold1 = mndvi\_images.select('MNDVI').gt(-1).And(mndvi\_images.select('MNDVI').lt(0.2)).selfMask()
> ^
> IndentationError: unexpected indent
> 
> 
> 

How can I fix it?

---

When I run it's still error like this

```
AttributeError                            Traceback (most recent call last)
Input In [3], in <cell line: 120>()
    115 print(mndvi_images.getInfo())
    118 # CREATE VEGETATION CLASS
--> 120 threshold1 = mndvi_images.select('MNDVI').gt(-1).And(mndvi_images.select('MNDVI').lt(0.2)).selfMask()
    121 threshold2 = mndvi_images.select('MNDVI').gt(0.2).And(mndvi_images.select('MNDVI').lt(0.4)).selfMask().multiply(2)
    122 threshold3 = mndvi_images.select('MNDVI').gt(0.4).And(mndvi_images.select('MNDVI').lt(0.6)).selfMask().multiply(3)

AttributeError: 'ImageCollection' object has no attribute 'gt'

```