# numpy.put() in Python

• Last Updated : 22 Oct, 2020

The numpy.put() function replaces specific elements of an array with given values of p_array. Array indexed works on flattened array.

`Syntax: numpy.put(array, indices, p_array, mode = 'raise')`

Parameters :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

```array   : array_like, target array
indices : index of the values to be fetched
p_array : array_like, values to be placed in target array
mode    : [{‘raise’, ‘wrap’, ‘clip’}, optional] mentions how out-of-bound indices will behave
raise : [default]raise an error
wrap  : wrap around
clip  : clip to the range

```
 `# Python Program explaining``# numpy.put()`` ` `import` `numpy as geek`` ` `a ``=` `geek.arange(``5``)``geek.put(a, [``0``, ``2``], [``-``44``, ``-``55``])``print``(``"After put : \n"``, a)`

Output :

```After put :
[-44,   1, -55,   3,   4]
```
 `# Python Program explaining``# numpy.put()`` ` `import` `numpy as geek`` ` `a ``=` `geek.arange(``5``)``geek.put(a, ``22``, ``-``5``, mode``=``'clip'``)``print``(``"After put : \n"``, a)`

Output :

`array([ 0,  1,  2,  3, -5])`

Note :
These codes won’t run on online-ID. Please run them on your systems to explore the working
.
This article is contributed by Mohit Gupta_OMG 😀. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.