![]() |
To split the elements of a given array with spaces we will use numpy.char.split(). It is a function for doing string operations in NumPy. It returns a list of the words in the string, using sep as the delimiter string for each element in arr.
Example 1: Python3
Output : ['PHP C# Python C Java C++'] [list(['PHP', 'C#', 'Python', 'C', 'Java', 'C++'])] Time Complexity: O(1) – The time complexity of importing a module is considered constant time. Example 2: Python3
Output: ['Geeks For Geeks'] [list(['Geeks', 'For', 'Geeks'])] Time complexity: O(n), where n is the length of the input array. Example 3: Python3
Output: ['DBMS OOPS DS'] [list(['DBMS', 'OOPS', 'DS'])] The time complexity of the code is O(n), where n is the length of the input string. The auxiliary space complexity of the code is O(n), |
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |