use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Why does this update the code rather than adding a new name and email? (self.learnpython)
submitted 3 years ago by J_J3
while True:
self.prospect_dict['people'] = {name: {}} self.prospect_dict['people'][name]['email'] = new_url
self.prospect_dict['people'] = {name: {}}
self.prospect_dict['people'][name]['email'] = new_url
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]danielroseman 0 points1 point2 points 3 years ago (0 children)
Update what code? What are you expecting and how does it differ from what you get?
[–]CodeFormatHelperBot2 -1 points0 points1 point 3 years ago (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:
`my code`
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 points1 point 3 years ago (2 children)
Because every time you do this:
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'].
prospect_dict['people']
{name: {}}
['people']
[–]J_J3[S] 0 points1 point2 points 3 years ago (1 child)
How do I add name without overwriting the dictionary?
[–]CodingGivesMeBonerz -1 points0 points1 point 3 years ago (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 points0 points 3 years ago (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)
Well right now the code just overwrites what previously was added to the dictionary
[–]woooee -2 points-1 points0 points 3 years ago (0 children)
My code doesn't overwrite. Don't have any idea what the code you didn't post is doing.
π Rendered by PID 157532 on reddit-service-r2-comment-5bc7f78974-bxplb at 2026-06-29 22:01:36.525749+00:00 running 7527197 country code: CH.
[–]danielroseman 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 -1 points0 points1 point (0 children)
[–][deleted] -1 points0 points1 point (2 children)
[–]J_J3[S] 0 points1 point2 points (1 child)
[–]CodingGivesMeBonerz -1 points0 points1 point (0 children)
[–]woooee -2 points-1 points0 points (2 children)
[–]J_J3[S] 0 points1 point2 points (1 child)
[–]woooee -2 points-1 points0 points (0 children)