Slicing selects a substring from a string using square brackets and colon-separated indices. In [start:stop:step], start is included, stop is excluded, and step sets how many characters to skip. Positive steps move left to right; negative steps move right to left. section 7.2
[start_index:stop_index:step]
Use this syntax pattern to see how start, stop, and step fit together. section 7.2
Separate a first and last name
For “Aqua Man,” find the space, then slice from the start to the space for “Aqua” and from just after the space to the end for “Man.” section 12.2
Listing 12.2. Storing the first and last names in variables
space = name1.find(" ") #1
name1_first = name1[0:space] #2
name1_last = name1[space+1:len(name1)] #3
space = name2.find(" ") #4
name2_first = name2[0:space] #4
name2_last = name2[space+1:len(name2)] #4
See the assignments that find the space and store each name using slices. section 12.2















