Q:

Write a NumPy program to replace "PHP" with "Python" in the element of a given array

0

Write a NumPy program to replace "PHP" with "Python" in the element of a given array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array(['PHP Exercises, Practice, Solution'], dtype=np.str)
print("\nOriginal Array:")
print(x)
r = np.char.replace(x, "PHP", "Python")
print("\nNew array:")
print(r)

Sample Input:

(['PHP Exercises, Practice, Solution'], dtype=np.str)

Sample Output:

Original Array:
['PHP Exercises, Practice, Solution']

New array:
['Python Exercises, Practice, Solution']

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now