this code is not very safe you can very easily move past the ending positionand if you try to go home on an empty fileit will crash these examples are kept short to make them readablebut that doesn' mean they are defensiveyou can improve the error checking of this code as an exerciseit might be great opportunity to expand your exception handling skills the document class itself is hardly changedexcept for removing the two methods that were moved to the cursor classclass documentdef __init__(self)self characters [self cursor cursor(selfself filename 'def insert(selfcharacter)self characters insert(self cursor positioncharacterself cursor forward(def delete(self)del self characters[self cursor positiondef save(self) open(self filename' ' write('join(self characters) close(we simply updated anything that accessed the old cursor integer to use the new object instead we can test that the home method is really moving to the newline characterd document( insert(' ' insert(' ' insert(' ' insert(' ' insert(' ' insert('\ ' insert(' '