Faced an interview question in Python that was as follow?
ex: input = (\'192.168.15.1\', \'.\', -1) ===> output = (192, 168, 15, 1) input = (\'192.168.15
Simple and recursive.
def split_str(s,c,i): if i == 0: return [s] else: head, _, rest = s.partition(c) if rest: return [head] + split_str(rest, c, i - 1) return [head]