Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DevNet Help
#6
Why would it be written like that? It's written the way it is because that made sense to Guido.

You keep using the work iteration, I don't think you understand what it means. This:

temp['id'] = id
Is assigning to an index. That assigns a single value to a single key in the dictionary. This is plain old indexing (getting a single value out of a dictionary):

id = temp['id']
Iteration is for loops. So this would be iteration:

for key in temp:
    print(key, temp[key])
That gets all the keys out of the dictionary. Generally, you get all the key/value pairs out of the dictionary together with the items method:

for key, value in temp.items():
    print(key, value)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
DevNet Help - by benniehanas - Aug-07-2019, 03:29 PM
RE: DevNet Help - by ichabod801 - Aug-07-2019, 05:25 PM
RE: DevNet Help - by benniehanas - Aug-07-2019, 07:41 PM
RE: DevNet Help - by ichabod801 - Aug-08-2019, 01:37 AM
RE: DevNet Help - by benniehanas - Aug-08-2019, 06:05 PM
RE: DevNet Help - by ichabod801 - Aug-08-2019, 06:28 PM
RE: DevNet Help - by benniehanas - Feb-04-2020, 11:51 PM

Forum Jump:

User Panel Messages

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