Jun-22-2018, 08:04 PM
What about a dict of rooms, and you pick one from there?
import random rooms = {} def get_next_room_from(current_room): next_room = None while not next_room or next_room == current_room: next_room = random.choice(list(rooms.keys())) return next_room def entryway(): print("Welcome to the entryway. Bye!") next_room = get_next_room_from("entryway") return next_room def conservatory(): print("This is the conservatory. There's plants and wicker couches here.") next_room = get_next_room_from("conservatory") return next_room rooms["entryway"] = entryway rooms["conservatory"] = conservatory running = True current_room = "entryway" while running: current_room = rooms[current_room]() running = "q" != input("Type 'q' to stop.").lower()