docs icon indicating copy to clipboard operation
docs copied to clipboard

[Bug/Error] Subject: CodeByte example issue using namedtuple defaults parameter

Open l2es opened this issue 1 year ago • 2 comments

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

l2es avatar Feb 08 '24 14:02 l2es

I can take the issue to remove references to defaults if needed

l2es avatar Feb 12 '24 08:02 l2es

Hi.

Can i work on bug/error? Thanks

ogumbaiyke avatar Feb 22 '24 22:02 ogumbaiyke

Can I work on this error?

Electromagnet83 avatar Mar 26 '24 17:03 Electromagnet83

Could I work on this?

StephRP12 avatar Mar 27 '24 22:03 StephRP12

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

ShreeManekar avatar Apr 22 '24 06:04 ShreeManekar

Hi @ishg-153 this issue is assigned to you

cigar-galaxy82 avatar Jun 18 '24 18:06 cigar-galaxy82

🌸 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!

github-actions[bot] avatar Jun 26 '24 09:06 github-actions[bot]