ДЗ3

mail@pastecode.io avatar
unknown
python
7 months ago
1.5 kB
2
Indexable
Never
import random


def game_roshambo(choice, result) -> None:
    print()
    print("=====Start Game rock, paper, scissors=====")
    print()

    computer_choice = random.choice("rps")
    user_choice_filtered = str.lower(choice)
    print("--------------------------------")
    print("Your select – ", str.capitalize(choice))
    print("Computer select —", str.capitalize(computer_choice))
    if str.lower(choice) == computer_choice:
        print("Result of game – Draw")
    elif str.lower(choice) == "r" and computer_choice == "p":
        result["computer"] += 1
        print("------Computer Wins------")
    elif str.lower(choice) == "r" and computer_choice == "s":
        result["player"] += 1
        print("------Player Wins------")
    elif str.lower(choice) == "p" and computer_choice == "s":
        result["computer"] += 1
        print("------Computer Wins------")
    elif str.lower(choice) == "p" and computer_choice == "r":
        result["player"] += 1
        print("------Player Wins------")
    elif str.lower(choice) == "s" and computer_choice == "r":
        result["computer"] += 1
        print("------Computer Wins------")
    elif str.lower(choice) == "s" and computer_choice == "p":
        result["player"] += 1
        print("------Player Wins------")


    print("Score: Computer >", result["computer"], "—", result["player"],"<")


result = {"computer": 0, "player": 0}
choise = input("Select R/P/S – ")
game_roshambo(choice=choise, result=result)

Leave a Comment