""" Example from lecture 13 oct. What if the builtin "str"-class didn't exist? Then we could write our own, and here's a simple toy version which implements the useful split-method. """ class Tekst: def __init__(self, innhold): self.innhold = innhold def split(self, arg = ' '): res = [] word = '' for e in self.innhold: if e != arg: word += e elif len(word) > 0: res.append(word) word = '' res.append(word) return res line = Tekst("All work and no play makes Jack a dull boy.") words = line.split() print(words)