The first blog in my life , Scissors stone cloth games
# -*- codeing = utf-8 -*-
# @Time : 2021/10/22 14:36
# @Author : Ning Hongkang
# @File : scissors .py
# @Software : PyCharm
import random
choices = ["Rock", "Scissors", "Paper"]
computer = random.choice(choices)
player = False
cpu_score = 0 # Initial score of computer
player_score = 0 # Player's initial score
while True:
player = input("Rock, Scissors or Paper" ).title()
# Judge the choice between computer and player
if player == computer:
print("tie!")
elif player == "Rock":
if computer == "Paper":
print("you lose!", computer, "covers", player)
cpu_score += 1
else:
print("you win!", player, "smashes", computer)
player_score += 1
elif player == "Paper":
if computer == "Scissors":
print("You lose!", computer, "cut", player)
cpu_score += 1
else:
print("You win!", player, "covers", computer)
player_score += 1
elif player == "Scissors":
if computer == "Rock":
print("You lose...", computer, "smashes", player)
cpu_score += 1
else:
print("You win!", player, "cut", computer)
player_score += 1
elif player == 'E': # Output results , Out of the loop
print("Final Scores:")
print(f"computer:{cpu_score}")
print(f"Player:{player_score}")
break
else:
print("That's not a valid play. Check your spelling!")
computer = random.choice(choices)