Commas not commaing

I am creating a text based game by using a dictionary setup. I keep getting flagged for forgetting commas but I can’t see why.

def Definitions():
     RoomContainer = {
           'Dungeon Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                            'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '',}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '',}, 
                          '': {'descr': '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            'Torture Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'thumbscrew': {'descr: 'You pick the thumbscrew', 'cost of health': 0, 'Item': 'thumbscrew', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            'Trapdoor Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            'False Door Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            ' Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            ' Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            ' Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
            ' Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''}, 
                          'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': ''}, 
                          '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '', 'Statuses': ''}},
                          'Statuses': {'': {'descr': '',  'Status_Choices': ''}, '': {'descr': '',  'Status_Choices': ''},
                          'SpecialCriterion': '', SpecialCriterionAnswer = []}, 
      }

Here is the error:

 def Definitions():
...      RoomContainer = {
...            'Dungeon Room': {'descr': '', directions: {'north': '', 'south': '', 'east': '', 'west': ''},
...                             'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '',}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '',},
  File "<stdin>", line 4
    'Choices': {'': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '',}, '': {'descr: '', 'cost of health': 0, 'Item': '', 'ItemRequired': '',},
                     ^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

Can anyone help or explain what I should do differently?

FIXED

What do you think of this particular section?

1 Like

This section, if it is in ‘Choices’, is where I am going to input different choices the player can input and have resultant deductions to health and descriptions of what they did and what happened.

Yep. Tell me about these two sections:

'Dungeon Room': {'descr': '', directions: ...

'Choices': {'': {'descr: '', 'cost of health': ...

Spot the difference :slight_smile:

Are you saying that they are the same?
Because they are not, if you would look closely you would see that choices is inside Dungeon Room, this is so that I can have unique choices for each room.

Look at the colours. String literals are in green. Are all of the bits that should be green actually green? If not, why not?

2 Likes

I think that is just a visual error.
Notice that lots of things are contained in quotes but aren’t green.

To be honest, I find it rather rude that you just dumped that huge amount of code on us instead of reducing it. And if you had reduced it to a minimal still failing case, you likely even would’ve found the problem yourself.

2 Likes

That’s a nice opinion.
But why don’t you rephrase it to be nicer:

Hey, could you please reduce your code so that the error is easier to find?

See, doesn’t that work better.

Apparently not, because the example is still not edited to be shorter.

When you say there’s “visual error”, there isn’t. The syntax highlighter is actually hinting at what’s wrong and how Python sees what you wrote.

Start with creating a new dictionary with just the top level of keys. Then add one more level. see where it falls apart.

1 Like

No. The things that are in quotes are green and the things that aren’t in quotes aren’t green. Or, to put it another way, the things that aren’t green aren’t in quotes.

1 Like

Because I didn’t just want to inform you that a reduction would be good, but that the big dump was bad (not neutral).

There’s a good chance they won’t repeat the typo so it won’t fall apart. I’d instead remove more and more from the full failing code until it stops failing, then go one step back to see what made the change.

Although… If they do it your way and it doesn’t fall apart so they end up with working code, I guess that’s good, too :-). They just won’t learn what the problem was (unless they’re able to diff with the first attempt).