Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is the sequence of numbers generated by the range() function a tuple?

On an online course, the teacher says that range() produces a tuple, adding that this is the reason why we have to convert it into a list (thanks to the list() function) if we want to modify it.

Is this statement true ?

Because in the official documentation, they dont talk about tuple at all in the range() section : https://docs.python.org/3/tutorial/controlflow.html#the-range-function

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Starting with python3, range returns a range object which is a sequence type which, among other things, can be iterated to create a list out of it.

Relevant docs about the range type.

Before that, it used to return a list, like Klaus commented. (docs)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading