Generate N-grams from a given text. **Example:** For the text 'hello world' and n=2, the output should be ['hello', 'world', 'hello world']. **Constraints:** 1 <= n <= 5, text length <= 100.
Test Cases
Test Case 1
Input:
'hello world', 2Expected:
['hello', 'world', 'hello world']Test Case 2
Input:
'this is a test', 1Expected:
['this', 'is', 'a', 'test']+ 3 hidden test cases