我正在用python为我的第一个脚本项目编写一个基于文本的游戏,但我不知道如何访问嵌套字典中的最后一个值。我试图访问键“item”的值,这样当玩家进入一个房间时,它会显示该房间中的物品。然后,通过玩家的输入,物品将被添加到库存中。我在挣扎,所以我感谢你的帮助
rooms = {'Living Room': {'South': 'Study', 'North': 'Kitchen', 'East': 'Bedroom', 'West': 'Bathroom'},
'Bedroom': {'North': 'Dining Room', 'West': 'Living Room', 'South': 'Sunroom', 'item': 'Glasses'},
'Dining Room': {'West': 'Kitchen', 'South': 'Bedroom', 'item': 'Napkin'},
'Kitchen': {'South': 'Living Room', 'East': 'Dining Room', 'West': 'Basement', 'item': 'Cheese'},
'Basement': {'East': 'Kitchen', 'South': 'Bathroom', 'item': 'Catnip'},
'Bathroom': {'East': 'Living Room', 'North': 'Basement', 'South': 'Walk-in Closet', 'item': 'Water'},
'Walk-in Closet': {'North': 'Bathroom', 'East': 'Study', 'item': 'Shoes'},
'Study': {'North': 'Living Room', 'East': 'Sunroom', 'West': 'Walk-in Closet', 'item': 'Cotton Balls'},
'Sunroom': {'North': 'Bedroom', 'West': 'Study', 'item': 'Cat'}
}
目前没有回答
相关问题 更多 >
编程相关推荐