Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple python code error
#3
Interesting. I thought it would raise a NoneType error instead. As I understand it, adding the second index requires an object to work. So, the interpreter is raising the KeyError because the key doesn't exist and so cannot have a value.

To make this work, you'll need to set the values to dicts before setting the those values.
Reply


Messages In This Thread
Simple python code error - by cls0724 - Mar-11-2020, 03:31 PM
RE: Simple python code error - by jefsummers - Mar-11-2020, 04:32 PM
RE: Simple python code error - by stullis - Mar-11-2020, 04:43 PM
RE: Simple python code error - by cls0724 - Mar-12-2020, 10:21 AM
RE: Simple python code error - by DeaD_EyE - Mar-12-2020, 10:41 AM
RE: Simple python code error - by stullis - Mar-12-2020, 07:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with simple code JacobSkinner 1 360 Mar-18-2024, 08:08 PM
Last Post: deanhystad
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 514 Nov-07-2023, 04:32 PM
Last Post: snippsat
  Code error from Fundamentals of Python Programming van Richard L. Halterman Heidi 12 1,752 Jul-25-2023, 10:32 PM
Last Post: Skaperen
  Syntax error while executing the Python code in Linux DivAsh 8 1,694 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,601 Mar-27-2023, 07:38 AM
Last Post: buran
  help me simple code result min and max number abrahimusmaximus 2 951 Nov-12-2022, 07:52 AM
Last Post: buran
  Error in if-then-else python code Led_Zeppelin 6 2,422 Jul-27-2022, 07:53 PM
Last Post: deanhystad
  Simple encoding code ebolisa 3 1,491 Jun-18-2022, 10:59 AM
Last Post: deanhystad
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 1,838 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
  Simple code question about lambda and tuples JasPyt 7 3,416 Oct-04-2021, 05:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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