I'm trying to follow the usage example of namedtuple( )
from the documentation, but I keep getting namedtuple is not defined
.
Asked
Active
Viewed 3,760 times
4

gmelodie
- 411
- 4
- 18

Paw in Data
- 1,262
- 2
- 14
- 32
-
5You haven't imported it yet. `from collections import namedtuple` – revliscano May 17 '20 at 23:44
-
Oh yeah I'm so stupid. Thank you! – Paw in Data May 18 '20 at 17:40
-
lol don't worry. Those things happen a lot. – revliscano May 18 '20 at 17:41
1 Answers
10
You need import collections
up top, then you can do collections.namedtuple
You can also do from collections import namedtuple
and it should work like in the docs

pacukluka
- 728
- 4
- 18