Python Forum
why is this dictionary giving a Keyerror?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why is this dictionary giving a Keyerror?
#2
The key of your dictionary is all strings.
Your array right_hand_numbers is full of integers.
That means you are trying to access the key - of which its type is a string - using an int, so it doesn't find anything and throws an error.
What you want is:
diagramCanvas.create_text(10 + dotposition * 5, dotYposition[str(dotposition)], text='.')
or optionally, make everything in right_hand_numbers a string.
Reply


Messages In This Thread
RE: why is this dictionary giving a Keyerror? - by DreamingInsanity - Dec-11-2019, 08:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Accessing a dictionary - KeyError ?? eoins 1 3,505 Jun-06-2018, 06:14 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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