FAQ: Working with Lists in Python - Consecutive Lists: Range

This community-built FAQ covers the “Consecutive Lists: Range” exercise from the lesson “Working with Lists in Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Scientist
Analyze Data with Python
Computer Science
Analyze Financial Data with Python
Build Chatbots with Python
Build Python Web Apps with Flask
Data Analyst

Learn Python 3
CS101 Livestream Series

FAQs on the exercise Consecutive Lists: Range

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi. There seems to be an issue with this problem. In the second part of the p, it asks to print the range in list form. However, I could also pass the exercise by solely printing range form. This didn’t really make sense, and I had to research and practice a bit with the compiler. I wish you can fix this issue. Thanks in advance!

2 Likes

i’m stuck here too:
zero_to_seven = range(0,8)
print(list(zero_to_seven))

produces in the output:
[0, 1, 2, 3, 4, 5, 6, 7]

but it gives me an error Did you create the range zero_to_seven with numbers from 0 to 7?
yes, it’s shown above??
confused :-S

1 Like

For whatever reason, it wants you to do the single range input (i.e., zero_to_seven=range(8)) even though the lesson was meant to demonstrate how to range based on a two input statement.

3 Likes

most likely an error in your desctiption in:

Consecutive Lists: Range

4/12

it say:
The list() function takes in a single input for the object you want to convert.
However you use range() against it which outputs for instance 0, 9 - this are two arguments. You may want to correct this.

I don’t think it is an error.

my_range = range(10)

print(my_range) # range(0, 10) 
print(type(my_range)) # <class 'range'>

my_list = list(my_range) 
print(my_list) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In the description, first an object of the range class is created via the statement my_range = range(10).
The object returned by range is a single object of the range class.

Then, this object is passed as an argument to the list function in the statement my_list = list(my_range).
The list function accepts one argument only (in this example, the my_range object).

When calling range, we can pass it a single argument (stop) [start defaults to 0, step to 1] or we can pass it two arguments (start, stop) [step defaults to 1] or we can pass it three arguments (start, stop, step). All of these calls will result in a single object of the range class.

The list function can accept at most one argument. If we omit the argument, then an empty list is created. If we provide an argument, then only one argument is allowed.

Hence, the statement

The list() function takes in a single input for the object you want to convert.

seems correct.

ok got it… thanks for clarification I did some testing w/ the python interpretador and can confirm it returns an object. I wish the lesson here would have given more details on what the function range actually is returning.