""" i am having a bit of trouble with my whoWins function and my menue. i can get all of my other functions to run from main but whoWins just doesnt seem to want to work no matter what i try.i am also unsure if the dictionaries etc for the whoWins function are to be placed inside the function or left at the top of the program. i am also unsure if i have correctly placed my program in the autopicks function for the menue. i think t might be an indentation problem or something like that. any help will be greatly appreciated. cheers heaps joel"""

import random
import string
Ascore = 0
Bscore = 0
Dscore = 0
table = {1:"Rock", 2:"Paper",3:"Scissors"}

turnTuple = ()

Awins = {(2,1):"Paper beats rock - Player A wins",
         (1,3):"Rock beats scissors - Player A wins",
         (3,2):"Scissors beat paper - Player A wins."}

Bwins = {(1,2):"Paper beats rock - Player B wins",
         (3,1):"Rock beats scissors - Player B wins",
         (2,3):"Scissors beat paper - Player B wins."}

Cdraws = {(1,1):"Its a draw.",
          (2,2):"Its a draw.",
          (3,3):"Its a draw."}


    
    
def showMenu(): # Using dictionary for the menu
    selection = {'1': 'All computer generated',
                 '2': 'Quit'}
    print
    print
    print "Welcome to Rock, Paper, Scissors"
    print "================================"
    print
    print " \t\t\t\tInstructions\t\t\t\t\t\n The aim of this game is to play rock paper scissors. The computer is to \
            simulate the whole game by producing the results for each game along with a statement declaring who has won the match."


    print
    print "Enter your selection"
    print
    print "  1. ", selection['1'] 
    print
    print
    print "  2. ", selection['2']
    print
    
    # Now use try ..except to handle input for menu
    # for both KeyError and NameError and
    # call game choice functions
    
    while 1:
        prompt = "Your Choice: "
        choice = string.upper(raw_input(prompt))
        try:
            selection[choice]
        except KeyError:
            print "'%s' is not a valid option. Try again." % choice
            print
        if choice == '1':
            autoPlay()
        elif choice == '2':
            return

def autoPlay(): # re-use of ass2A
    print "This is computer generated auto picks!"
    print

# Here is the code so far
# for players A and B:
    while Ascore < 10 and Bscore < 10:
        x = 0
        y = 0
        print "hello"
    
        x = random.randrange(1,4)
        y = random.randrange(1,4)
        turnA = table[x]
        turnB = table[y]
        turnTuple = (x,y)
            
    print "player A chose:",turnA
    print "player B chose:",turnB
    print
def whoWins():  
    if turnTuple in Awins:
        print Awins[turnTuple]
        Ascore = Ascore + 1
    elif turnTuple in Bwins:
        print Bwins[turnTuple]
        Bscore = Bscore + 1
    elif turnTuple in Cdraws:
        Dscore = Dscore + 1
        print Cdraws[turnTuple]
  
#TESTING 1 2 3
def summary():
    print
    print "A scored: ", Ascore
    print "B scored: ", Bscore
    print "Draws: ", Dscore

def main():
    
    showMenu()
    whoWins()
    summary()
    
if __name__ == '__main__':
    main()

Add a print statement at the beginning of who wins to see if you actually enter it or not. If the value of turnTuple is not found, nothing will happen. And this definitely should be a class IMHO. It's time to learn classes. It will make coding a lot easier.

def whoWins(): 
     ##--------- added  -----------------------------------------
     print "executing whoWins", turnTuple

     if turnTuple in Awins:
        print Awins[turnTuple]
        Ascore = Ascore + 1
     elif turnTuple in Bwins:
        print Bwins[turnTuple]
        Bscore = Bscore + 1
     elif turnTuple in Cdraws:
        Dscore = Dscore + 1
        print Cdraws[turnTuple]/CODE]
     ##--------- added  -----------------------------------------
     else:
          print "turnTuple not found", turnTuple
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.