ソースコード
#coding:utf-8
# じゃんけん
import random
import os
cnt = winCnt = loseCnt = draw = 0
y = True
while y == True:
os.system('clear')
cnt += 1
print(f'{cnt}回目')
#PCの手を乱数で決める
pc = random.randint(0,2)
#プレイヤーの入力
hand = int(input(' 1: チョキ 2: パー 3: ぐー \n'))-1
while hand < 0 or hand > 2:
print ("入力ミス\n")
hand = int(input(' 1: チョキ 2: パー 3: ぐー \n'))-1
#じゃんけん勝敗の判断
if hand == pc:
print('あいこ! (~^~)\n')
draw += 1
elif hand == (pc + 1) % 3:
print('パソコンの勝ち! (T_T) \n')
loseCnt += 1
else:
print('あなたの勝ち!!! \(^O^)/ \n')
winCnt += 1
#ゲーム続けるか
ask = input(' Enter: ゲームを続ける N/n: やめる \n')
if ask in ['N','n']:
y = False
#結果表示
jrate = winCnt / cnt
print(f'\n プレイ回数は{cnt}回\n {winCnt}勝ち, {loseCnt}負け, {draw}引き分け\n 勝率は{jrate*100:.1f}%.\n' )
print("BYE")