0

I'm new to python and trying to learn by consulting various sources.

There is a python manual at

http://www.physics.nyu.edu/pine/pymanual/html/chap3/chap3_arrays.html

which contains the following paragraph


3.2.2. Creating and modifying lists

Python has functions for creating and augmenting lists. The most useful is the range function, which can be used to create a uniformly spaced sequence of integers. The general form of the function is range([start,] stop[, step]), where the arguments are all integers; those in square brackets are optional:

In [26]: range(10)      # makes a list of 10 integers from 0 to 9
Out[26]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

So according to this source, range(10) creates a list. However when I run range(10) on anaconda3 I get

In [1]: range(10)
Out[1]: range(0, 10)

I'm not sure what range(0,10) is, but whatever it is, it looks very different from the above. What's going on?

DavidG
  • 24,279
  • 14
  • 89
  • 82
  • what version are you using? – Ma0 Nov 10 '17 at 09:23
  • 5
    The manual is for Python 2, but you are using Python 3. `range` in Python 3 is much like `xrange` in Python 2. For that, see https://stackoverflow.com/q/94935/1639625 – tobias_k Nov 10 '17 at 09:23
  • 1
    The correct reference is this: https://docs.python.org/3/library/stdtypes.html#range – EdChum Nov 10 '17 at 09:24

0 Answers0