Python Forum
why do we need dict.get() ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why do we need dict.get() ?
#11
(May-12-2023, 08:05 AM)buran Wrote: It's doing exactly that, except that I don't understand what would be the purpose of the second argument of your dict.put() - i.e. it doesn't make sense to have 3 arguments for what you describe

the first argument would be the key. if the key is present, store argument 2 under that key. if the key is not present, add the key with argument 3 stored under it. i could even add a 4th argument as an additional test against the stored value under the found key (for argument 2). but i don't know if it should be a != test or an is not test.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020