collection data types stridingfor examplex[:: but this will give us the items at index positions and so on we can fix this by giving an initial starting indexso now we have [ :: ]and this gives us slice of the items we want to set each item in the slice to we need list of sand this list must have exactly the same number of as there are items in the slice here is the complete solutionx[ :: [ len( [ :: ]now list is [ we used the replication operator *to produce list consisting of the number of we needed based on the length ( the number of itemsof the slice the interesting aspect is that when we assign the list [ to the strided slicepython correctly replaces [ ]' value with the first [ ]' value with the second and so on lists can be reversed and sorted in the same way as any other iterable using the built-in reversed(and sorted(functions covered in the iterators and iterable operations and functions subsection lists also have equivalent methodslist reverse(and list sort()both of which work in-place (so they don' return anything)the latter accepting the same optional arguments as sorted(one common idiom is to case-insensitively sort list of strings--for examplewe could sort the woods list like thiswoods sort(key=str lowerthe key argument is used to specify function which is applied to each itemand whose return value is used to perform the comparisons used when sorting as we noted in the previous section on string comparisons ( )for languages other than englishsorting strings in way that is meaningful to humans can be quite challenging for inserting itemslists perform best when items are added or removed at the end (list append()list pop()the worst performance occurs when we search for items in listfor exampleusing list remove(or list index()or using in for membership testing if fast searching or membership testing is requireda set or dict (both covered later in this may be more suitable collection choice alternativelylists can provide fast searching if they are kept in order by sorting them--python' sort algorithm is especially well optimized for sorting partially sorted lists--and using binary search (provided by the bisect module)to find items (in we will create an intrinsically sorted custom list class list comprehensions small lists are often created using list literalsbut longer lists are usually created programmatically for list of integers we can use list(range( ))or if we just need an integer iteratorrange(is sufficientbut for other lists using for in loop is very common supposefor examplethat we wanted to produce list of the leap years in given range we might start out like thisleaps [for year in range( )sorted(