如何在Python初学者中循环

如何在Python初学者中循环,python,python-3.x,Python,Python 3.x,我刚刚收到这学期的第一份编程作业;制作一个石头布剪刀游戏,直到一个玩家赢了三次。我已经设法让它运行了,但是我很难让它回到开始 ps1 = 0 ps2 = 0 from random import radint player1 = imput('R, P, S') print (player1, " vs ", end='') chosen = randint(1,3) #print (chosen) if chosen == 1: player2 = 'R' elif ch

我刚刚收到这学期的第一份编程作业;制作一个石头布剪刀游戏,直到一个玩家赢了三次。我已经设法让它运行了,但是我很难让它回到开始

ps1 = 0
ps2 = 0


from random import radint
player1 = imput('R, P, S')

print (player1, " vs ", end='')
chosen = randint(1,3)
    #print (chosen)
if chosen == 1:
    player2 = 'R'
elif chosen == 2:
    player2 = 'P'
else:
    player2 = 'S'

print(player2)

if player1 == player2:
    print("Draw")
elif player1 == 'R' and player2 == 'S'
    ps1 = ps1 + 1
        print("Point to Player 1")
elif player1 == 'R' and player2 == 'P'
    ps2 = ps2 + 1
        print("Point to Player 2")
elif player1 == 'P' and player2 == 'S'
    ps2 = ps2 + 1
        print("Point to Player 2")
elif player1 == 'P' and player2 == 'R'
    ps1 = ps1 + 1
        print("Point to Player 1")
elif player1 == 'S' and player2 == 'R'
    ps2 = ps2 + 1
        print("Point to Player 2")
elif player1 == 'S' and player2 == 'P'
    ps1 = ps1 + 1
        print("Point to Player 1")
if ps1 = 3
    print("Player 1 wins!")
elif ps2 = 3
    print("Player 2 wins!")

你需要一个while循环,每次重新开始时检查是否有赢家。当你在循环中找到一个赢家时,把while条件设为False,这样它就不会再循环了。或者像下面提醒的那样“休息”一下。

是的。那更好