My If Statements don't work...
Hello! I am making a game, and I wrote two if statements, and when I hit the run button and type in an answer, it goes to only one if statement when it is supposed to go to the other. I don't know what's happening!
Is this the repl? https://repl.it/@PythoNinja/WealthyMountainousConversions#main.py
As far as I can see this is the best Python 3 game I've ever seen! If this helped then please choose this as the correct answer to your question! Happy coding and a great day
@JosephSanthosh Thank you, but I must admit, it is not my game. I used it to make a map for a different game, and it is the exact same thing as @Mkhoi's STACKMAN game. The game I am doing is a team game, Dungeon of the Dark Lord. This is the link: https://repl.it/@Ninjas/Dungeon-of-the-Dark-Lord#main.py . In main.py, on line 13 is a def cocker. Under that is two if statements and a login system. The If Statements are the problems.
@PythoNinja oh, you have to write it like this:
if sl == "Load" or sl == "load" or sl == "1":
And same thing for the other if statement
Your problems are because of if you use the 'and', 'or',... keyword then the condition after that is separated from the condition before. So it checks if 'load' or '1' is true, and they are, then runs the code below and skip the next if statement. I hope this is a good explaination :)
@PythoNinja hmm, i don't really know how to fix this.
BTW, i see you're trying to make the user input be capitalized, you have to add a pair of brackets after the 'upper' keyword there, like this:
sl = input().upper(). And in the cocker function, change the conditions like this:
if sl == "LOAD" or sl == "2":
That's because the input will be capitalized but the conditions only check for input that isn't capitalized, so your code wouldn't run. And i don't know why the numbers don't work, i think they are unaffected by the capitalization but for some reason they don't work?