My Python list notes

From Got Opinion Wiki
Revision as of 10:16, 7 February 2022 by Paul (talk | contribs) (initial page creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
>>> l = []
>>> type(l)
<class 'list'>
>>> l.append(1)
>>> l
[1]
>>> l = range(10)
>>> l
range(0, 10)
>>> type(l)
<class 'range'>
>>> l = range(10).list
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'range' object has no attribute 'list'
>>> l = list(range(10))
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> type(l)
<class 'list'>
>>>
To Python Programming