and may leave your cursor bit indentedin say print cinstead)myjob "hackerfor in myjobprint(cend=' "kin myjob true "zin myjob false 'spamin 'abcspamdeftrue step through itemsprint each ( formfound not found substring searchno position returned the for loop assigns variable to successive items in sequence (herea stringand executes one or more statements for each item in effectthe variable becomes cursor stepping across the string' characters here we will discuss iteration tools like these and others listed in table - in more detail later in this book (especially in and indexing and slicing because strings are defined as ordered collections of characterswe can access their components by position in pythoncharacters in string are fetched by indexing-providing the numeric offset of the desired component in square brackets after the string you get back the one-character string at the specified position as in the languagepython offsets start at and end at one less than the length of the string unlike choweverpython also lets you fetch items from sequences such as strings using negative offsets technicallya negative offset is added to the length of string to derive positive offset you can also think of negative offsets as counting backward from the end the following interaction demonstratess 'spams[ ] [- (' '' ' [ : ] [ :] [:- ('pa''pam''spa'indexing from front or end slicingextract section the first line defines four-character string and assigns it the name the next line indexes it in two wayss[ fetches the item at offset from the left--the one-character string ' ' [- gets the item at offset back from the end--or equivalentlyat offset ( (- )from the front in more graphic termsoffsets and slices map to cells as shown in figure more mathematically minded readers (and students in my classessometimes detect small asymmetry herethe leftmost item is at offset but the rightmost is at offset - alasthere is no such thing as distinct - value in python strings in action