List & Dictionary – Multimedia

This round 4 we learned about list and dictionary. We use list to put a group of things in a variable. Dictionary is used to defined type of variable. To make us understand more about those we go to to practice those. I have choose a project in there that call RPG. You can test it here:

We use Python dictionary to make room and also item for player. We use a lot of if statement so that the player can interact with the game. One example from there is If the room have monster and you are there then show game over.

Here is some example of dictionary :

rooms = {

  'Hall' : { 
  'south' : 'Kitchen',
  'east' : 'Dining Room',
  'item' : '1key'

  'Kitchen' : {
  'north' : 'Hall',
  'item' : 'Granny'
  'Dining Room' : {
  'west' : 'Hall',
  'south' : 'Living Room',
  'item' : 'shotgun'
  'Living Room' : {
  'west' : 'Kitchen',
  'east' : 'UnderGround'
  'UnderGround' : {
  'west' : 'Living Room',
  'north' : 'SecretBase',
  'item' : '2key'
  'SecretBase' : {
  'south' : 'UnderGround'

Here is some example of If/Else Statement :

 #if they type 'go' first
   if move[0] == 'go':
 #check that they are allowed wherever they want to go
   if move[1] in rooms[currentRoom]:
 #set the current room to the new room
     currentRoom = rooms[currentRoom][move[1]]
 #there is no door (link) to the new room
     print('You can\'t go that way!')

Leave a Reply

Your email address will not be published. Required fields are marked *