Python Forum
A strange value in dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A strange value in dictionary
#8
(Jan-07-2019, 01:40 PM)python_user_n Wrote: But in the returned dictionary I found an item with a key of the type 'int' that have a value of 'int'.
Maybe it's .setdefault() method behavior(predicted?). Thanks.


once again - show us your full code. we cannot guess what your list that you pass to the function looks like. what you get from the function and what is expected output?

(Jan-07-2019, 01:40 PM)perfringo Wrote: Shouldn't this function give NameError as d is not defined?

I guess the line d = dict() is in the doc-string by mistake :-)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
A strange value in dictionary - by python_user_n - Jan-07-2019, 01:21 PM
RE: A strange value in dictionary - by buran - Jan-07-2019, 01:23 PM
RE: A strange value in dictionary - by buran - Jan-07-2019, 01:35 PM
RE: A strange value in dictionary - by perfringo - Jan-07-2019, 01:40 PM
RE: A strange value in dictionary - by buran - Jan-07-2019, 01:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Nested dictionary acting strange Pedroski55 2 2,157 May-13-2021, 10:37 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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