What is the return value of the range() function in python?

python, python-3.5, python-3.x, range

Solution

The book you are reading probably uses Python 2, where `range` returns a list.

In Python 3, `range` returns an immutable sequence type instead.

Problem

I thought that the range() function returns a list with the arguments that you have put inside the parentheses. But when I type `range(4)` in IDLE, I get `range(0, 4)` as output. Similarly, when I type `print(range(4))`, I also get `range(0, 4)` as output. I am currently using python 3.5. I am currently studying python with the following eBook: "How To Think Like a Computer Scientist" and in that eBook, they provide active code blocks where you can run python code. And when I run `print(range(4))` in there, I do get the list that I expected, i.e. `[0, 1, 2, 3]`. Can someone explain this to me? Thanks in advance!

Original source