concept Python Tutor in category python

This is an excerpt from Manning's book Python Workout: 50 ten-minute exercises.
You can work through a version of this code in the Python Tutor at http://mng.bz/ vx1q.
When you retrieve a single element from a sequence (figure 3.1), you can get any type at all. String indexes return one-character strings, but lists and tuples can contain anything. By contrast, when you use a slice, you’re guaranteed to get the same type back--so a slice of a tuple is a tuple, regardless of the size of the slice or the elements it contains. And a slice of a list will return a list. In figures 3.2 and 3.3 from the Python Tutor, notice that the data structures are different, and thus the results of retrieving from each type will be different.