This gives me an error:
with open('username.json', "r+") as f:
json.dump(current_contents, f)
newlist= json.load(f)
print(newlist)
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This works:
with open('username.json', "r+") as f:
json.dump(current_contents, f)
with open('username.json') as f:
current_contents = json.load(f)
print(current_contents)
But I have to open up 2 'with' blocks to do it. What's the point of "r+" if it can't read and write within the same block?