Python noob, Adventure game error

Here is the error and my code. It is supposed to be a basic game where a player goes room to room collecting items to defeat a villain, if you can help, thanks! If not, still thanks! (Not sure why the bottom of the code looks like that in the discussion post)
You are in Starting Area.
Traceback (most recent call last):
File “”, line 48, in
room_dict = rooms[current_room]
NameError: name ‘rooms’ is not defined

** Process exited - Return Code: 1 **
Press Enter to exit terminal

def show_instructions():
# print the main menu and commands
print(“Fire Thrower Adventure Game”)
print(“Collect all 7 of your missing items across the map to defeat the Fire Thrower.”)
print(“Move commands: south, north, east, west”)
print(“Add to Inventory: get ‘item name’”)

def main():
rooms = {‘Starting Area’ : {‘name’: ‘Starting Area’, ‘east’: ‘Security Desk’,‘west’: ‘Kitchen’, ‘south’: ‘Closet’,
‘north’: ‘The Foyer’, ‘text’: ‘Starting Area.’},
‘Foyer’: {‘name’: ‘The Foyer’, ‘item1’: ‘Map & Keys’, ‘south’: ‘Starting Area’,‘east’: ‘Heavy equip. room’,
‘text’: ‘You are in the Foyer.’},
‘Heavy equip. room’: {‘name’: ‘Heavy equip. room’, ‘item2’: ‘Water cannon’, ‘west’: ‘Foyer’,
‘text’: ‘You are in the Heavy equip room’},
‘Security Desk’: {‘name’: ‘Security Desk’, ‘west’: ‘Starting Area’, ‘east’: ‘Holding Cell’,
‘north’: ‘Operations Room’, ‘item7’: ‘Fire Extinguisher’,‘text’: ‘You are at the security desk’},
‘Operation Room’: {‘name’: ‘Operations Room’, ‘item8’: ‘Fire Thrower’, ‘south’: ‘Security Desk’,
‘text’: ’ You are in The Operations Room with Flame Thrower!’},
‘Holding Cell’: {‘name’: ‘Holding Cell’, ‘west’: ‘Security Desk’, ‘text’: ‘You are in the Holding Cell’},
‘Kitchen’: {‘name’: ‘The Kitchen’, ‘item5’: ‘Water’, ‘north’ : ‘Armory’, ‘text’: ‘You are in the Kitchen’},
‘Armory’ : {‘name’ : ‘The Armory’, ‘item6’: ‘Handcuffs’, ‘south’: ‘Kitchen’},
‘Closet’ : {‘name’: ‘The Closet’, ‘item2’: ‘Fire Resistant Clothing’, ‘east’: ‘Vehicle Storage’,
‘north’: ‘Starting Area’, ‘text’: ‘You are in the Closet.’},
‘Vehicle Storage’: {‘name’: ‘Vehicle Storage’, ‘item3’: ‘Go Cart’, ‘west’: ‘the Closet’,
‘text’: ‘You are in Vehicle Storage.’},


directions = [‘north’, ‘south’, ‘east’, ‘west’,]
current_room = ‘Starting Area’
inventory =

while True:
if current_room == ‘Holding Cell’:
if len(inventory) == 7:
print(‘You have captured Fire Thrower!’)
print(‘You need more items!, You were burned!’)
# display current location
print(‘You are in {}.’.format(current_room))
print(‘inventory:’, inventory)
room_dict = rooms[current_room]
if “item” in room_dict:
item = room_dict[‘item’]
if item not in inventory:
print(‘Do you see a’, item)
# get user input
command = input("Now what? ").split()
# movement
if command[0] == ‘go’:
if command[1] in directions:
room_dict = rooms[current_room]
if command[1] in room_dict:
current_room = room_dict[command[1]]
# bad movement
print(‘Wrong way.’)
print(“Invalid entry”)

elif command[0] in ['exit', 'quit']:
    print('Thanks for playing!')
        # get item
elif command[0] == 'get':
    if command[1] == item:
        print(item, "collected")
            print('Invalid command')
        # bad command
            print('Invalid input')


You are looking at the way Python manages namespaces. Some code:

>>> def make_room():
...     rooms = {'reception room' : 'Roses room', 'kitchen' : 'Cookers paradise'}
...     return rooms
>>> make_room()
{'reception room': 'Roses room', 'kitchen': 'Cookers paradise'}
>>> rooms
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'rooms' is not defined

I have defined rooms in make_room, even executed it, why doesn’t it know room? That is because the definition of room in make_room creates a local reference, that does not “escape” from the function.

I already prepared the next step. make_room returns the room dictionary, so when I write:

>>> rooms_in_script = make_room()
>>> rooms_in_script
{'reception room': 'Roses room', 'kitchen': 'Cookers paradise'}
>>> rooms_in_script['kitchen']
'Cookers paradise'

That works. If you want something from a function, return it.

As an aside, try to run your code more often, after you have written little code. Now you have to search all of that code, if you test more often, you know better where to look for the issue.

Thanks so much for the reply, I will adjust my code and give it a shot.