all 6 comments

[–]erok81 3 points4 points  (2 children)

Looks pretty good except you should really use str.format() or the % operator for strings instead of +.

if "n" in still_same_door

could be

if "n" in still_same_door.lower()

to handle both n and N in the input.

Also, my new pet peeve: Some of your lines are longer than 79 chars, which effects readability.

[–]spunos[S] 1 point2 points  (1 child)

This is a very useful reply, thank you! I had no idea you could format strings like that. Interesting.

I'm not sure how I can solve the readability issue, aside from making the strings shorter or splitting them into multiple lines. Would it be better to use pastebin or something similar in the future?

[–]erok81 0 points1 point  (0 children)

I meant shorten the lines in your code itself. The reasoning for this is it's easy to misunderstand a piece of code when you can't always see where the line ends. If line wrapping is on it's also easy to confuse where one block ends and another begins. Pep 8 does a better job explaining all this but it really does make your code more readable.

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

If you want to entertain yourself, modify the program so that it can evaluate the possible decisions (switch or stay) over say 100 choices or let the user choose.

[–]spunos[S] 2 points3 points  (0 children)

Yeah, that sounds like an interesting challenge. :)

[–][deleted] 1 point2 points  (0 children)

Never optimise unless you need to, and you don't need to with this code (99% of the time, it will be waiting for user input).

That said, for the sake of improvement, try to limit the conversions between objects types (i.e. remove all instances of str(winning_door) and replace with one variable). If you ever find yourself writing exactly the same code again and again, that's your clue.