Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
creating a dictionary
#2
Im not really sure what you are trying to accomplish. Are you trying to retain Edge in the dictionary?
for x in V:
    Graph[x.v1] = x.v2
Quote:TypeError: list indices must be integers, not Edge
Theres not much else to say. List indices must be an int, whereas you are sending an Edge object. You shoudnt need to do this anyways, as python for loops iterates the objects within. Here x is each Edge object as it iterates through the list. Rarely do you need the index.

Also regarding your naming conventions
http://python-forum.io/Thread-Basic-Nami...ions-PEP-8
Recommended Tutorials:
Reply


Messages In This Thread
creating a dictionary - by bluefrog - Oct-25-2016, 04:30 PM
RE: creating a dictionary - by metulburr - Oct-25-2016, 04:51 PM
RE: creating a dictionary - by ichabod801 - Oct-25-2016, 05:06 PM
RE: creating a dictionary - by bluefrog - Oct-25-2016, 06:08 PM
RE: creating a dictionary - by Yoriz - Oct-25-2016, 06:19 PM
RE: creating a dictionary - by nilamo - Oct-25-2016, 06:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Class-Aggregation and creating a list/dictionary IoannisDem 1 2,005 Oct-03-2021, 05:16 PM
Last Post: Yoriz
  Creating a dictionary from a list Inkanus 5 3,261 Nov-06-2020, 06:11 PM
Last Post: DeaD_EyE
  Creating Dictionary form LOG /text file DG1234 7 5,678 Feb-13-2019, 08:08 PM
Last Post: DG1234
  creating a username and pword program using a #def statement and #dictionary zcode12 3 3,239 Oct-14-2018, 04:41 AM
Last Post: volcano63
  Creating dictionary from list kerzol81 4 4,459 Oct-23-2017, 11:40 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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