docs
docs copied to clipboard
[Bug/Error] Subject: CodeByte example issue using namedtuple defaults parameter
Actual Behavior
From the namedtuple python collections module docs : https://www.codecademy.com/resources/docs/python/collections-module/namedtuple When you run the Codebyte Example you get this error :
Traceback (most recent call last):
File "main.py", line 4, in <module>
myNamedTuple = namedtuple('myNamedTuple', ['a', 'b', 'c'], defaults=[0, 2, 4])
TypeError: namedtuple() got an unexpected keyword argument 'defaults'`
After some research, it seems that the Python version used by the workspace does not support the defaults parameter. The defaults parameter requires at least Python version 3.7.0.
Expected Behavior
The CodeByte output should be
('a', 'b', 'c')
---
myNamedTuple(a=0, b=1, c=2)
2
{'a': 0, 'b': 1, 'c': 2}
---
myNamedTuple(a=0, b=1, c=3)
---
{'a': 0, 'b': 2, 'c': 4}`
On what browser(s) are you seeing the problem?
Chrome
Code of Conduct
- [X] By submitting this issue, I agree to follow Codecademy Doc's Code of Conduct.
For Maintainers
- [ ] Labels added
- [ ] Issue is assigned
I can take the issue to remove references to defaults if needed
Hi.
Can i work on bug/error? Thanks
Can I work on this error?
Could I work on this?
from collections import namedtuple
myNamedTuple = namedtuple('myNamedTuple', ['a', 'b', 'c'], default=0) nt = myNamedTuple(b=1, c=2) print(nt) print(nt._asdict()) nt2 = myNamedTuple(c=3) print(nt2._asdict())
#try this code
Hi @ishg-153 this issue is assigned to you
🌸 Thanks for closing this Issue! Please head over to the Docs Forum if you have any questions about Docs, or reply to the thread on Possible Content Discussion to share ideas and collaborate with other contributors, maintainers, or super users to determine good future issues that will help expand Docs!