anonymous
  • anonymous
Hi everybody: Can somebody explain to me how to remove() from a dictionary? I can delete but I can't figure out how to remove! d{'four':4,'five':5,'six':6,'seven':7} how do i remove the second key and value 'five':5 from this dictionary?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
There is del and pop. Delete and remove seem like the same thing to me but here is some code. >>> d={'four':4,'five':5,'six':6,'seven':7} >>> del d['five'] >>> d {'four': 4, 'seven': 7, 'six': 6} >>> item = d.pop('six') >>> d {'four': 4, 'seven': 7} >>> item 6
anonymous
  • anonymous
Thanks, I know how to pop() it, just in the book I was reading it says you can use remove(), but it doesnt explain how? So that's what I was trying to figure... I guess no one uses remove in dictionaries then, and I shouldnt worry about it?
anonymous
  • anonymous
Yeah, these seem to be the standard options. I cannot find a remove function and dicts don't have a remove method. Lists on the other hand do have a remove method. May be an error in the book ... not sure.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Thanks, how long you been learning python msmithnova?
anonymous
  • anonymous
Only since I started doing some online courses on edX and Coursera that required it. They started toward the end of September. So about 6.5 months, but I have also done C, SML, ruby, racket, rails, html, css, php, js, cuda, ai, cryptography, algorithms, mobile robots, game theory, algebra, calculus, physics and digital audio, video and photography online courses during that time as well. I've completed 5 courses on Edx and 14 courses on Coursera during that time so only part of it was dedicated to Python. I've been busy, lol.

Looking for something else?

Not the answer you are looking for? Search for more explanations.