looks like it' working we could connect keyboard' letter and arrow keys to these methods and the document would track everything just fine but what if we want to connect more than just arrow keys what if we want to connect the home and end keys as wellwe could add more methods to the document class that search forward or backwards for newline characters (in pythona newline characteror \ represents the end of one line and the beginning of new onein the string and jump to thembut if we did that for every possible movement action (move by wordsmove by sentencespage uppage downend of linebeginning of whitespaceand more)the class would be huge maybe it would be better to put those methods on separate object solet us turn the cursor attribute into an object that is aware of its position and can manipulate that position we can move the forward and back methods to that classand add couple more for the home and end keysclass cursordef __init__(selfdocument)self document document self position def forward(self)self position + def back(self)self position - def home(self)while self document charactersself position- !'\ 'self position - if self position = got to beginning of file before newline break def end(self)while self position len(self document characters and self document charactersself position!'\ 'self position + this class takes the document as an initialization parameter so the methods have access to the content of the document' character list it then provides simple methods for moving backwards and forwardsas beforeand for moving to the home and end positions