Mar-01-2017, 11:00 PM
Some points on your code. You ask about printing the room contents. The join method would be useful there:
>>> ', '.join(['spam', 'spam', 'eggs']) 'spam, spam, eggs'You have a lot of if statements like:
if choice == 'N' or choice == 'n': direction = 0Note that this can be simplified:
if choice.lower() == 'n': direction = 0That's the standard way to do a case-insensitive comparison in Python. However, I note that you are mapping to indexes for another list. This can be done easily with the find method of strings:
direction = 'nswe'.find(choice.lower())Find will return the index in 'nswe' of choice, which is lower cased to match 'nswe'. So, if choice is 's', find will return 1. If choice is not in 'nswe', find will return -1, which is what your code is expecting.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures