DIANAKODLAND0544

labe

Nov 14th, 2025
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import time
  2.  
  3. rooms = {
  4.     'Comienzo': {'habitaciones': ['1'], 'items':[]},
  5.     '1': {'habitaciones': ['Comienzo', '2', '3'], 'items':[]},
  6.     '2': {'habitaciones': ['1'], 'items':['llave']},
  7.     '3': {'habitaciones': ['1', '4'], 'items':[]},
  8.     '4': {'habitaciones': ['3', '5'], 'items': []},
  9.     '5': {'habitaciones': ['4', 'Salida'], 'items':[]}
  10. }
  11.  
  12. room = 'Comienzo'
  13. llave = 0
  14.  
  15. while True:
  16.     print("=====================")
  17.     print("Estas en la habitación", room)
  18.     for new_room in rooms[room]['habitaciones']:
  19.         print("puedes ir a la habitacion", new_room)
  20.  
  21.     choice_room = input("¿Que habitacion eliges?")
  22.  
  23.     if choice_room not in rooms[room]['habitaciones']:
  24.         print("Esa habitación no exite")
  25.         time.sleep(1)
  26.         continue
  27.  
  28.     if choice_room == 'Salida' and llave == 0:
  29.         print("No tienes llave")
  30.         continue
  31.  
  32.     if choice_room == 'Salida' and llave == 1:
  33.         print("Ganaste")
  34.         break
  35.    
  36.     room = choice_room
  37.  
  38.     if 'llave' in rooms[room]['items']:
  39.         llave = 1
  40.         print("Encontrate una llave")
  41.         rooms[room]['items'].remove('llave')
Advertisement
Add Comment
Please, Sign In to add comment