index expression end+'- cin the get call in the previous examplefor instanceis really the string 'end- cand refers to one character back from end because end points to just beyond the last character in the text stringthis expression refers to the last character itself the - extension effectively strips the trailing \ that this widget adds to its contents (and which may add blank line if saved in filesimilar index string extensions let you name characters ahead (+ )name lines ahead and behind (+ - )and specify things such as line ends and word starts around an index (lineendwordstartindexes show up in most text widget calls text marks besides row/column identifier stringsyou can also pass positions as names of marks--symbolic names for position between two characters unlike absolute rowcolumn positionsmarks are virtual locations that move as new text is inserted or deleted (by your script or your usera mark always refers to its original locationeven if that location shifts to different row and column over time to create markcall the text object' mark_set method with string name and an index to give its logical location for instancethis script sets the insert cursor at the start of the text initiallywith call like the first one hereself text mark_set(insert' 'self text mark_set('linetwo'' 'set insert cursor to start mark current line the name insert is predefined special mark that identifies the insert cursor positionsetting it changes the insert cursor' location to make mark of your ownsimply provide unique name as in the second call here and use it anywhere you need to specify text position the mark_unset call deletes marks by name text tags in addition to absolute indexes and symbolic mark namesthe text widget supports the notion of tags--symbolic names associated with one or more substrings within the text widget' string tags can be used for many thingsbut they also serve to represent position anywhere you need onetagged items are named by their beginning and ending indexeswhich can be later passed to position-based calls for exampletkinter provides built-in tag namesel-- tkinter name preassigned to string 'sel'--which automatically refers to currently selected text to fetch the text selected (highlightedwith mouserun either of these callstext self text get(sel_firstsel_lasttext self text get('sel first''sel last'use tags for from/to indexes strings and constants work the names sel_first and sel_last are just preassigned variables in the tkinter module that refer to the strings used in the second line here the text get method expects two indexesto fetch text names by tagadd first and last to the tag' name to get its start and end indexes to tag substringcall the text widget' tag_add method with tag name string and start and stop positions (text can also be tagged as added in insert callsto remove tag from all characters in range of textcall tag_remove tkinter tourpart