Skip to content
Advertisement

Assign a range to a variable

Whenever I try to assign a range to a variable like so:

JavaScript

Then try to print the variable:

JavaScript

It simply prints ‘range(10, 50)’ instead of all the numbers in the range. Why is this?

Advertisement

Answer

Thats because range returns a range object in Python 3. Put it in list to make it do what you want:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement