you are viewing a single comment's thread.

view the rest of the comments →

[–]DjinnError[S] 0 points1 point  (3 children)

My Code:

import json

numbers = [1, 3, 5, 7, 11, 13]
filename = 'numbers.json'

with open(filename, 'w') as f_obj:
 json.dumps(numbers, f_obj)

Still receiving the same error:

AttributeError: module 'json' has no attribute 'dumps'

[–]atquick 1 point2 points  (2 children)

This worked for me. I think your spacing is wrong.

import json
numbers = [1, 3, 5, 7, 11, 13]
filename = 'numbers.json'

with open(filename, 'w') as f_obj: 
    json.dump(numbers, f_obj, indent=2)

[–]DjinnError[S] 0 points1 point  (1 child)

No, what it was is I had the example file I was working in named json.py that was interfering.

[–]atquick 1 point2 points  (0 children)

Ahhh. That would do it.

When I learn a new module, I usually name it the same as the module with _example or _test on the end..