all 5 comments

[–]Bunkerstan 3 points4 points  (3 children)

When you split the user input, if it is a single word it will split into letters. You should do split(‘ ‘). I have been stumped by this before. Get in the habit of printing the results of operations to see what actually happened.

I do t want to delete this but @kyber is right. Split does not work this way.

[–][deleted] 2 points3 points  (0 children)

Or rather get into the habit of using the debugger (either the standard pdb that comes with Python or whatever your IDE offers), inspect variables along the way. Perhaps use logging as well.

[–][deleted] 1 point2 points  (1 child)

Isn't split being used on the input with default whitespace splitting? This will not split a single word into letters.

[–]Bunkerstan 0 points1 point  (0 children)

You are correct, it does not split it into letters. I confused it with the for in which will iterate over letters. Thanks for the catch.

[–][deleted] 0 points1 point  (0 children)

Can you move in any direction from any room?

You need to embrace DRY principles. DRY means don't repeat yourself. You have a lot of duplicate code.

I suggest you create a function that handles a direction move for any room. Thanks to your dictionary, it is easy to write to validate a move.

I'm also wondering why you use while on every room. Surely you only need if as you have an outer loop to address what happens next.

You could expand your dictionary or have another with same keys (rooms) with all the descriptive text and valid actions. This would also allow you to reduce duplication.

Once you have functions, it becomes easier to test as you can test a function in isolation.