slicing in the seconds 'spamfor in range(len( )) [ : [: print(send='pams amsp mspa spam 'spamfor in range(len( )) [ : [:iprint(xend='spam pams amsp mspa for repeat counts move front item to end for positions rear part front part trace through these one iteration at time if they seem confusing the second creates the same results as the firstthough in different orderand doesn' change the original variable as it goes because both slice to obtain parts to concatenatethey also work on any type of sequenceand return sequences of the same type as that being shuffled-if you shuffle listyou create reordered listsl [ for in range(len( )) [ : [:iprint(xend='[ [ [ works on any sequence type we'll make use of code like this to test functions with different argument orderings in and will extend it to functionsgeneratorsand more complete permutations in --it' widely useful tool nonexhaustive traversalsrange versus slices cases like that of the prior section are valid applications for the range/len combination we might also use this technique to skip items as we gos 'abcdefghijklist(range( len( ) )[ for in range( len( ) )print( [ ]end=' herewe visit every second item in the string by stepping over the generated range list to visit every third itemchange the third range argument to be and so on in effectusing range this way lets you skip items in loops while still retaining the simplicity of the for loop construct loop coding techniques