Apr-08-2019, 01:49 AM
Hi - I am new to Python and was attempting to code based on the guidance at https://www.youtube.com/watch?v=8uJFN7OZ...vF&index=4. I am running into a code format issue with elif (line 35). Can you please help me identify the format issue
import random def msg(room): if room[msg]==' ': return "you have entered the " + room['name']+' ' else: return room['msg'] def main(): dirs = (0,0,0,0) entrance = {'name':'Entrance way','directions':dirs,'msg':''} livingroom = {'name':'Livingroom','directions':dirs,'msg':''} hallway = {'name':'Hallway','directions':dirs,'msg':''} diningroom = {'name':'Diningroom','directions':dirs,'msg':''} kitchen = {'name':'Kitchen','directions':dirs,'msg':''} familyroom = {'name':'Familyroom','directions':dirs,'msg':''} entrance['directions'] = (kitchen, livingroom, 0, 0) livingroom['directions'] = (diningroom, 0, 0, entrance) hallway['directions'] = (0, kitchen, 0, familyroom) kitchen['directions'] = (0, diningroom, entrance, hallway) diningroom['directions'] = (0, 0, livingroom, kitchen) familyroom['directions'] = (0,hallway,0,0) rooms = [livingroom,hallway,diningroom,kitchen,familyroom] room_with_eggs = random.choice(rooms) eggs_delivered = False room = entrance print (' can you find the basket') while True: if eggs_delivered == True and room[name] == 'Entrance way': print('you have the basket') break; elif not eggs_delivered and room['name'] == room_with_eggs['name']: eggs_delivered = True print ('There\'s is the basket and Johnny is sleeping' + 'right next to it and! you have delivered the eggs' + 'get out quick') room['msg']= ('you are back in the room' + room['name'] + '! you already delivered the eggs' + 'get out of here before Johnny wakes up' ) else: print(msg(room)) room['msg'] = 'You are back in the '+ room['name'] stuck = True main()