house = ('House', 'you are in the house sitting in the family\'s chair.') guestRoom = ('Guest Room', 'family\'s guess room.') wall = ('Wall', 'You can not move further in this direction.') transitions = { house[0]:(guestRoom, wall), guestRoom[0]: (house,), wall[0]: (house,), } location = house while True: print location[1] print 'You can go to these places:' for (i, t) in enumerate(transitions[location[0]],1): print i, t[0] choice = int(raw_input('choose one')) location = transitions[location[0]][choice-1]
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question