Python newbie exercise: Rock Paper Scissors
Question: I've been trying to code a simple game of RPS where the user plays against the
computer. There's just 1 iteration at this point (because I got stuck...) and
no validation whether the user's input is valid. The problem I got stuck with
is that whatever I tried to do in order to get the computer's and the user's
score stored in a variable, it they kept being equal to 0, no matter what
indentation I tried or wherever I tried to place the return. (as you could see
in my code below... some parts that I tried with no luck are commented out).
Ideally, since I plan on multiple iterations, I'd like the variables u and v
themselves to be updated and keep score, not just print who won the specific
iteration.

Can you help me understand what I'm doing wrong here?

Cheers

    
    
    from random import randrange
    rps = ["r", "p", "s"]
    
    
    
    def gameplay(user,comp):
        u = 0 #user's score
        v = 0 #computer's score
        print "Computer chose: " + comp
        if comp == user:
            pass
        elif comp == "r" and user == "p":
            u += 1
            #print u
            #return u
    
        elif comp == "r" and user == "s":
            v += 1
            #print v
            #return v
    
        elif comp == "p" and user == "s":
            u += 1
            #print u
            #return u
    
        elif comp == "p" and user == "r":
            v += 1
            #print v
            #return v
    
        elif comp == "s" and user == "r":
            u += 1
            #print u
            #return u
    
        elif comp == "s" and user == "p":
            v += 1
            #print v
            #return v
    
        return u
        return v
    
    gameplay(raw_input("your move?"),rps[randrange(3)])
    print u
    print v
    


Answer: just for fun ... see if you can understand this OOP implementation (its never
too early to start learning OOP)

    
    
    WIN,TIE,LOSE = 1,0,-1
    class RockPaperScissors:
        def __str__(self):
            return self.__class__.__name__
    class Rock(RockPaperScissors):
        def __cmp__(self,other):
            if isinstance(other,Rock): return TIE
            if isinstance(other,Paper): return LOSE
            return WIN
    
    class Paper(RockPaperScissors):
        def __cmp__(self,other):
            if isinstance(other,Paper): return TIE
            if isinstance(other,Scissors):return LOSE
            return WIN
    
    class Scissors(RockPaperScissors):
        def __cmp__(self,other):
            if isinstance(other,Scissors): return TIE
            if isinstance(other,Rock):return LOSE
            return WIN
    
    def RPS(ltr_code):
        return {'r':Rock,'p':Paper,'s':Scissors}[ltr_code.lower()]()
    
    
    player = RPS("r")
    computer = RPS("s")
    if player > computer:
        print "Player Wins! %s beats %s"%(player,computer)
    elif player < computer:
        print "Computer wins!! %s beats %s"%(computer,player)
    else: 
        print "Tied!! %s ties %s"%(computer,player)
    

