mercredi 9 janvier 2019

Is there a way of adding an item to a dictionary within an if statement with python?

I am making a text-based adventure game, and am trying to add an item to a directory on the basis that the player has a key in their inventory.

I have tried every solution I could find, and none of them worked. I think this is maybe because I have a different syntax to the other dictionaries.

    if 'key' in inventory:
    print('Well done for killing all monsters on the first floor! You can 
    now 
    travel upstairs from the hall')
    'Hall' ['upstairs'] = 'Landing'

     'Hall' : {
              'south' : 'Kitchen',
              'east'  : 'Dining Room',
              'north' : 'Library',
              'west' : 'Game Room',
            }, 

Please tell me another way to put

    'Hall' ['upstairs'] = 'Landing'

without changing all of the directory, as I have numerous other rooms.

Aucun commentaire:

Enregistrer un commentaire