Kodewick
Start learning →
Mini challenge←→0 / 100

Rock, paper, scissors

#099Mini challengeMixedStrings7 min

You play rock-paper-scissors with a friend and note each round as "yours-theirs", like "rock-scissors". Same throw is a draw. Write rps_winner(rounds) to return "you" if you won more rounds, "friend" if they did, and "tie" if even (or no rounds).

Examples
rps_winner(["rock-scissors", "paper-scissors", "rock-paper"])→'friend'
rps_winner(["paper-rock", "rock-rock"])→'you'
rps_winner([])→'tie'
main.py
def rps_winner(rounds):
    beats = {"rock": "scissors", "scissors": "paper", "paper": "rock"}
    me = 0
    friend = 0
    for r in rounds:
        mine, theirs = r.split("-")
        # your code here: skip a draw; my win adds to me, else to friend
        pass
    if me > friend:
        return "you"
    if friend > me:
        return "friend"
    return "tie"
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.