Okay, following up on the previous lecture, let's get into the Python three interpreter and see how does range behave in Python version three, let's consider a basic implementation of a range. So let's say R equals range of 10. Let's see are. And also let's check type of R. And indeed, we have class range. You can easily notice that unlike in Python, version two, where we would have got a list returned in Python three, range gets its own data type class range. However, if you want a list instead of a range object, you can simply apply the list function on this range.
So let's say list of R. And indeed, we get a list. What else can you do with ranges, you can use indexes, as we did with strings or lists to extract various elements from this range. For instance, let's say our have zero, return zero, or have minus one returns the last element which is nine. You can also verify if a certain value is a member of a range by using the in and not in keywords. So let's try 10. In our is false, seven not in are also false, because seven is a member of this range.
Finally seven in our returns true. Moreover, you can apply for instance, the index method to find out the index of a certain element within the range. So our dot index of four returns four. Of course, the index method is not that useful when working on a basic range, starting at zero and advancing with a step of one, since the index of any element is equal to the value of the element itself. However, when having more complex ranges, these methods can prove to be pretty useful. Finally, keep in mind that You cannot slice arrange, but what you can do is you can convert the range truelist using the list function, and then apply your slice.
For instance, let's try list of our, and now applying the slice as usual, starting at index two up to but not including index five, and this returns to three and four. There is a slice. It's a simple trick, but it works. Again, don't worry if you don't yet understand what iterators are all about. We will talk more about iterators. Later in the course after we will cover for loops and other several useful concepts to have a better understanding of this concept overall.