hi so i need to write a rock paper scissors game. when played in the command prompt it should look something like this
user input is in bold
press q at any time to quit
please choose rock(r), paper(p) or scissors(s): r
computer chose paper. you lose!
your score: 0 win(s), 1 loss(es), and 0 tie(s)
and it continues until you quit.
and please dont say how because this looks like an assignment youre not going to help me out. im not asking for the answers but rather tips or pointers in helping me make this work. thanks. :)

what im having problems on is looping all these functions together. and i dont understand how i can make the scores go up. if you could help me it would be greatly appreciated :)

heres my code:
[import random

x=('p','s','r')


def beats(throw):
if throw=='r':
return'p'
if throw=='p':
return 's'
if throw=='s':
return'r'


def winning_move(throw1, throw2):
if throw1==throw2:
return 'tie'
if throw1=='win':
return throw1
if throw2=='win':
return throw2

def me_vs_you(me, you):
if me=='r' and you=='s':
return 'win'
elif me=='s' and you== 'r':
return 'lose'
elif me=='r' and you=='p':
return 'lose'
elif me=='p' and you=='r':
return 'win'
elif me=='p' and you=='s':
return 'lose'
elif me=='s' and you=='p':
return 'win'
elif me=='s' and you=='s':
return 'tie'
elif me=='p' and you=='p':
return 'tie'
elif me=='r' and you=='r':
return 'tie'

def play_random_game():
if me_vs_you(me,you)=='win':
return 'win'
if me_vs_you(me, you)=='lose':
return 'lose'
if me_vs_you(me, you)=='tie':
return 'tie'

def count_games(num):
text=''
a=0
b=0
c=0
while play_random_game(x)=='win':
a +=1
while play_random_game(x)=='lose':
b +=1
while play_random_game(x)=='tie':
c +=1

def play_RPS(x):
print 'Press q at any time to quit'
text=''
while text!='q':
text=raw_input("Please choose rock(r), paper(p), or scissors(s):")
if text=='q':
print "Thanks for playing!"
break
elif text== 'r':
random_throw=random.choice(x)
print random_throw
elif text=='s':
random_throw=random.choice(x)
print random_throw
elif text=='p':
random_throw=random.choice(x)
print random_throw
else:
print "Invalid input!"]

Good for posting code. Not so good for not using the (CODE) button. When you re-paste, highlight your code and press the button (or press first, then paste between the code-tags). You really need that for Python: Indentation counts, and that is how you get it; you also get line numbers and code coloring: All good things.

Your code should look like something like this, at the very highest level:

outer_count = 100
results = {'win':0,'tie':0,'lose':0}
While True:
  choice = getUserInput()
  if choice.lower().startswith('q'):
     break
  else:
     choice = choice.lower()[0]
  computer_move = getComputerChoice()
  getAndPrintResults(choice,computer_move)
  outer_count -= 1
  if outer_count < 0:
    print("Get a LIFE! (I'm bored and quitting.)")
    break

Of course, you still have to write the bit that gets the user choice, the bit that generates the computer move and the bit that figures out and prints the results.

Code this one step at a time. So first, get the input and check that it is indeed 'r', 'p', or 's'. Then generate a random choice for the computer, etc. BTW you have a lot of redundant code in this function.

def play_RPS(x, num_games):
    print 'Press q at any time to quit'
    text=''
    while text!='q':
        text=raw_input("Please choose rock(r), paper(p), or scissors(s):")
        if text=='q':
            print "Thanks for playing!"
            break 

        if text not in ['r', 'p', 's']:
            print "incorrect letter entered"
        else:
            random_throw=random.choice(x)
            num_games += 1
            return random_throw, num_games

    return "*", num_games


##----- the rest of the code repeats the same thing
        elif text== 'r':
            random_throw=random.choice(x)
            print random_throw 
        elif text=='s':
            random_throw=random.choice(x)
            print random_throw
        elif text=='p':
            random_throw=random.choice(x)
            print random_throw
        else:
            print "Invalid input!"]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.