import numpy as np
str1 = np.array([['Python-NumPy-Exercises'],
['-Python-']])
print("Original array of string values:")
print(str1)
print("\nReplace '-' with '=' character in the said array of string values:")
print(np.char.strip(np.char.replace(str1, '-', '==')))
print("\nReplace '-' with ' ' character in the said array of string values:")
print(np.char.strip(np.char.replace(str1, '-', ' ')))
Sample Output:
Original array of string values:
[['Python-NumPy-Exercises']
['-Python-']]
Replace '-' with '=' character in the said array of string values:
[['Python==NumPy==Exercises']
['==Python==']]
Replace '-' with ' ' character in the said array of string values:
[['Python NumPy Exercises']
['Python']]
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer