代码运行器无法与程序输入配合使用

时间:2019-11-15 01:44:01

标签: python-3.x vscode-code-runner

单击右上角的播放按钮时使用Vs代码(来自代码运行程序扩展名) 它为我为用户所做的第一个输入投入了源的一半时间,因此它完全跳过了第一个输入。 例如:

(通过按钮从运行代码输出端子)

mwc-062194:python brendangallagher$ venv/bin/python -u 

"/Users/brendangallagher/Desktop/python/venv/Practice Problems/Rock_Paper_Scissors.py"

Player one enter your name!
#Above line is supposed to have an input from the user, but the below line is inserted
source /Users/brendangallagher/Desktop/python/venv/bin/activate

Player two enter your name!

我正在运行的代码:

def player1_turn(player1):
    satisfied = False
    play = str(input("{} enter Rock, Paper or Scissors!\n".format(player1)))
    play = play.lower()
    if play != 'rock' or play != 'paper' or play != 'scissors':
        while satisfied == False:
            if play == 'rock' or play == 'paper' or play == 'scissors':
                break
            else:
                play = str(input("{} enter Rock, Paper or Scissors!\n".format(player1)))
    return(play)


def player2_turn(player2):
    satisfied = False
    play = str(input("{} enter Rock, Paper or Scissors!\n".format(player2)))
    play.lower()
    if play != 'rock' or play != 'paper' or play != 'scissors':
        while satisfied == False:
            if play == 'rock' or play == 'paper' or play == 'scissors':
                break
            else:
                play = str(input("{} enter Rock, Paper or Scissors!\n".format(player2)))
    return(play)

playerAg = str(input("Player one enter your name!\n"))
playerAy = str(input("Player two enter your name!\n"))
player1_turn(playerAg)
player2_turn(playerAy)

0 个答案:

没有答案