# How to Delete Color Stops of Color Ramp using Python

I have Added a Color ramp in my node editor using a Script and I wan't that the Color Stops That Are Available by default Should be Deleted. before I add new stops I know how to add new stops but i don't Know how to remove the stops that are there by default using Python script. Can Anyone Help me Out Please

You can remove them but not the last one.

If cr_node is the color ramp node, stops are stored in cr_node.color_ramp.elements.

You can remove the element n by:

cr_node.color_ramp.elements.remove( cr_node.color_ramp.elements[n] )


But if you attempt to remove the last one, you will have this error message:

RuntimeError: Error: Element not found in element collection or **last element**


So you need to keep it and change its values:

cr_node.color_ramp.elements[0].color = your color