jeudi 12 décembre 2019

python while loop not working with if function in it [duplicate]

This question already has an answer here:

So basically this block of code is supposed to allow a player to either walk forward by typing "w" or "walk forward", alternatively, they could "stand still" and the if function for that would be executed. When the player chooses to walk forward the code breaks the while loop and this works every time, but for some reason, my while loop will only allow the player to "stand still" once (1 time) if the player tries to stand still a second time the code will not execute the if function and just break the loop.

WHY???

(i figure that I'm missing out on some vital understanding)

def PRESS_CONTINUE():
    text = raw_input("PRESS ENTER TO START")
    if text == "":
        clear()

import os
clear = lambda: os.system('clear')
clear()

print("(walk forward/stand still): ")
text = raw_input()
while text != "walk forward" "w":

    if text == "stand still":
        clear()
        print("You stand staring at the challenge in front of you...")
        PRESS_CONTINUE()
        clear()
        print("(walk forward/stand still): ")
        text = raw_input()
    break
print("You move into the shadows of the maze...")
PRESS_CONTINUE()

Aucun commentaire:

Enregistrer un commentaire