How to Create Your Own Python Split Function
The challenge
Write your own implementation of the built-in split
function in Python.
The following rules must be adhered to:
- the function cannot use, in any way, the original
split
orrsplit
functions, - the new function must be a generator,
- it should behave as the built-in
split
, so it will be tested that way — think ofsplit()
andsplit('')
The solution in Python
Option 1:
|
|
Option 2:
Option 3:
|
|
Test cases to validate our solution
|
|