Sep-19-2020, 01:21 AM
Hello, I am just learning python so bear with me.
I am trying to figure out why the output of the following two lines are different despite both of them returning a list.
In: [range(9)]
Out: [range(0, 9)]
In: list(range(9))
Out: [0, 1, 2, 3, 4, 5, 6, 7, 8]
In: type([range(9)])
Out: list
In: type(list(range(9)))
Out: list
I am guessing for the 2nd approach I am passing a range object in a list constructor. Is my guess corrcet?
I am trying to figure out why the output of the following two lines are different despite both of them returning a list.
In: [range(9)]
Out: [range(0, 9)]
In: list(range(9))
Out: [0, 1, 2, 3, 4, 5, 6, 7, 8]
In: type([range(9)])
Out: list
In: type(list(range(9)))
Out: list
I am guessing for the 2nd approach I am passing a range object in a list constructor. Is my guess corrcet?