Jun-20-2018, 08:39 PM
(This post was last modified: Jun-20-2018, 08:40 PM by ichabod801.)
Well, you could use the in operator, which sees if any one of the items in a container equals a specific value:
If you want to expand this you are going to have multiple functions doing similar things, and the code is going to be hard to maintain. If you find a problem in one function, you'll have to correct it in all of the similar functions. Much better is to keep the rooms and the information about the rooms in some sort of data structure, and to have functions that can operate on the information for any room, and keep track of where you are in the rooms. See the text adventures tutorial link in my signature for an example of how to do this.
if correct1 in Answer1:Then you could get rid of the for loop and just have the if/else clause. However, it appears you are only using Answer1 to handle different ways to capitalize 'push walls'. This is generally done with the lower method of the string, which converts it to lower case:
if correct1.lower() == 'push walls':Your use of global is problematic. You'll run into problems with multiple different variables using slightly different names. You should pass values to the functions as parameters, and get results out of them with return statements. This way you can pass values between functions without clogging the global namespace.
If you want to expand this you are going to have multiple functions doing similar things, and the code is going to be hard to maintain. If you find a problem in one function, you'll have to correct it in all of the similar functions. Much better is to keep the rooms and the information about the rooms in some sort of data structure, and to have functions that can operate on the information for any room, and keep track of where you are in the rooms. See the text adventures tutorial link in my signature for an example of how to do this.
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