# Adding Suffix to Numpy Array Elements In Python

In this tutorial, we are going to learn about adding the suffix to the Numpy array elements in Python. Firstly, let’s know what is Numpy and array.

**Numpy:**

Numpy is a Python module that supports large, multidimensional arrays and matrices. On the other hand, It also supports scientific calculations. Above all, It is also used for Machine learning and Deep learning.

An **array** is a data structure with the collection of items stored in the contagious memory locations.

To install Numpy type the following command in your command prompt.

pip install numpy

### Adding the suffix to the numpy array elements:-

Going further, we need to import NumPy module in our code. Let us know what a suffix is. **Suffix:- **A suffix is a morpheme added at the end of the word to form derivative (-ation, -ing). Let’s see how to add a suffix to the array.

Example:-

import numpy as np a = np.array(['Friend', 'Intern', 'Relation', 'Member']) print('Before adding suffix: ', a) suf = 'ship' a = np.array([sub + suf for sub in a]) print('After adding suffix:', a)

Output:-

Before adding suffix: ['Friend' 'Intern' 'Relation' 'Member'] After adding suffix: ['Friendship' 'Internship' 'Relationship' 'Membership']

In the above example, we have taken a Numpy array and printing it. As a result, the output of the array is same as we created. Now we are adding a suffix ‘Ship’ to the array elements by using ‘+’ operator and for loop. Again we are printing it after updating it. Finally, as a result, the output is the updated array with ‘ship’ to the elements of it.

Also, read:- NumPy concatenate in Python

## Leave a Reply