這是用python編寫岩石剪刀紙遊戲的代碼。 如果我運行的代碼,它的作品,但是,當它成爲領帶時,它會像這樣輸出。 無論如何,當我得到領帶的結果時,我可以消除打印(圓)嗎? 我想看看它如在示例底部所示岩石剪刀紙程序
********************* ROUND#1 ********* ************
挑選你的投球:[ock,[p] aper或[s] cissors? p 扎!
*********************#1 *********************
挑選你的投球:[ock,[p] aper或[s] cissors? s 電腦扔石頭,你輸了!
你的分數:0 電腦積分:1
********************* ROUND#3 ********* ************
挑選你的投球:[ock,[p] aper或[s] cissors? s 扎!
選擇你的選擇:[r] ock,[p] aper或[s] cissors? p 扎!
選擇你的選擇:[r] ock,[p] aper或[s] cissors? r 電腦扔剪刀,你贏了!
你的分數:2 電腦的得分:1
# A Python program for the Rock, Paper, Scissors game.
import random
def rock_paper_scissors():
''' Write your code for playing Rock Paper Scissors here. '''
user = 0
computer = 0
rounds = 1
print()
score = (int(input('How many points does it take to win? ')))
print()
while (computer < score and user < score):
RPS = random.randint(0,2)
if (RPS == 0):
RPS = 'rock'
elif (RPS == 1):
RPS = 'paper'
elif(RPS == 2):
RPS = 'scissors'
print('*'*21 + 'ROUND #'+str(rounds) + '*'*21)
print()
player = (input('Pick your throw: [r]ock, [p]aper, or [s]cissors? '))
if RPS == 'rock' and player == 'r':
print('Tie!')
elif RPS == 'rock' and player == 's':
print('Computer threws rock, you lose!')
computer+=1
rounds += 1
print()
print('Your Score: ',user)
print('Computer Score: ',computer)
elif RPS == 'rock' and player == 'p':
print('Computer threw rock, you win!')
user+=1
rounds +=1
print()
print('Your Score: ',user)
print('Computer Score: ',computer)
if RPS == 'paper' and player == 'p':
print('Tie!')
elif RPS == 'paper' and player == 'r':
print('Computer threw paper, you lose!')
computer +=1
rounds += 1
print()
print('Your Score: ',user)
print('Computer Score: ',computer)
elif RPS == 'paper' and player == 's':
print('Computer threw paper, you win!')
user +=1
rounds +=1
print()
print('Your Score: ',user)
print('Computer Score: ',computer)
if RPS == 'scissors' and player == 's':
print('Tie!')
elif RPS == 'scissors'and player == 'p':
print('Computer threw scissors, you lose!')
computer +=1
rounds+=1
print()
print('Your Score: ',user)
print('Computer Score: ',computer)
elif RPS == 'scissors' and player == 'r':
print('Computer threw scissors, you win!')
user +=1
rounds+=1
print()
print('Your Score: ',user)
print('Computer Score: ',computer)
print()
if user> computer:
print('*'*21 + 'GAME OVER' + '*'*21)
print('You win!')
else:
print('*'*21 + 'GAME OVER' + '*'*21)
print('Computer win!')
print()
def main():
print('ROCK PAPER SCISSORS in Python')
print()
print('Rules: 1) Rock wins over Scissors.')
print(' 2) Scissors wins over Paper.')
print(' 3) Paper wins over Rock.')
rock_paper_scissors()
main()
那麼問題是什麼? –