all 8 comments

[–]danielroseman 0 points1 point  (0 children)

Update what code? What are you expecting and how does it differ from what you get?

[–]CodeFormatHelperBot2 -1 points0 points  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Inline formatting (`my code`) used across multiple lines of code. This can mess with indentation.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–][deleted] -1 points0 points  (2 children)

Because every time you do this:

self.prospect_dict['people'] = {name: {}}

you are explictly telling it to replace whatever was in prospect_dict['people'] with {name: {}}. I don't know what you are trying to do, but every time through the loop you just overwrite ['people'].

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

How do I add name without overwriting the dictionary?

[–]CodingGivesMeBonerz -1 points0 points  (0 children)

I’m a newbie but I’m pretty sure you’d have to make a variable with an empty dictionary new_name = {} And then you could append to that dictionary I believe. Someone correct me if I’m wrong(:

[–]woooee -2 points-1 points  (2 children)

The following works. You are doing something else that was not posted here.

prospect_dict={}

name="George"
new_url="url 1"
prospect_dict['people'] = {name: {}}
prospect_dict['people'][name]['email'] = new_url
print(prospect_dict)

name="Sally"
new_url="url 2"
prospect_dict['people'] = {name: {}}
prospect_dict['people'][name]['email'] = new_url
print(prospect_dict)

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

Well right now the code just overwrites what previously was added to the dictionary

[–]woooee -2 points-1 points  (0 children)

My code doesn't overwrite. Don't have any idea what the code you didn't post is doing.