from random import randint

def menu():
    
    while True:
        print """ \n\n\n\n\n\n\n
  ____   ___   ____ _  __   ____   _    ____  _____ ____  
 |  _ \ / _ \ / ___| |/ /  |  _ \ / \  |  _ \| ____|  _ \ 
 | |_) | | | | |   | ' /   | |_) / _ \ | |_) |  _| | |_) |
 |  _ <| |_| | |___| . \   |  __/ ___ \|  __/| |___|  _ < 
 |_| \_\\___/ \____|_|\_\  |_| /_/   \_\_|   |_____|_| \_\
                                                          
  ____   ____ ___ ____  ____   ___  ____  ____  
 / ___| / ___|_ _/ ___|/ ___| / _ \|  _ \/ ___| 
 \___ \| |    | |\___ \\___ \| | | | |_) \___ \ 
  ___) | |___ | | ___) |___) | |_| |  _ < ___) |
 |____/ \____|___|____/|____/ \___/|_| \_\____/\n\n"""
        MenuInput = int(raw_input("""     
    MENU
        1. Rock, Paper, Scissors 
        0. Exit

        Your Choice:  """))
       
        if MenuInput in range (2):
            break
        else:
            print "\n\tInvalid Entry"
    return MenuInput

def match(choice1, choice2):
    if choice1 == choice2:
        print "You have a match, the computer wins."
        raw_input("Press Enter to continue")

def resetScores(user, comScore, gamez):
    user = 0
    comScore = 0
    gamez = 0

def firstChooserWins( chooserChoice, otherChoice ): 

    if chooserChoice == "Rock" and otherChoice == "Scissors":
        return True
    elif chooserChoice == "Paper" and otherChoice == "Rock":
        return True
    elif chooserChoice == "Scissors" and otherChoice == "Paper":
        return True
    else: 
        return False


def new(count, countL, game):
   
    if count == game:
        print "You win against the computer"
        return True
    elif countL == game:
        print "The Computer has beatin your ass"
        return True
    else:
        print "keep playing to win"
        return False

def same(a,b):
    if same(countWins, games):
        return False
    if same(countLost, games):
        return True
        
    
def playGame(): 
    choice = { 1:"Rock", 2:"Paper", 3:"Scissors" } 
    countWins = 0
    countLost = 0
    totalGames = countWins + countLost
    if totalGames > 0:
        return False
    com = "The Computer has won\nThe Computer has won\nThe Computer has won\n"
    you = "You have beatin the computer, congratulations\nYou have beatin the computer, congratulations\nYou have beatin the computer, congratulations\n"

   
    while menu() == 1:
        if totalGames == 0:
            userBestOf = float(raw_input("""
        How many games would you like to
        play best of with the computer? """))
        
        Avg = userBestOf / 2
        games = Avg + 1
             
        print "\tFirst player to %d Wins! " %games
          
        playerPick = int(raw_input(""" 
        Enter choice: 
        0 : Quit 
        1 : Rock 
        2 : Paper 
        3 : Scissors 

        Your choice : """))



        if playerPick == 0: 
            break 

        if playerPick not in choice.keys(): 
            print "\tInvalid choice" 
            continue 

        playerChoice = choice[playerPick] 
        computerChoice = choice[randint(1,3)] 

        print "\tYou chose %s, the computer chose %s" % ( playerChoice, computerChoice ) 
        
        if firstChooserWins( playerChoice, computerChoice ): 
            print "\tYou have won this round!"
            countWins += 1
        else: 
            print "\tYou lose!"
            countLost += 1

        totalGames += 1
        if match(playerChoice, computerChoice) == 1:
            countLost - 1
            return countLost
       
        print "\tYou have Won: ",countWins
        print "\tComputer has Won: ",countLost
        print "\tTotal Games: ",totalGames
        print "\tFirst player to %d Wins! " %games

        print "\tKeep playing, first to %d wins." % games
        if countWins == games:
            print you
            raw_input("Press Enter to exit")
            resetScores(countWin, countLost, games)
        
        if countLost == games:
            print com
            raw_input("Press Enter to exit")
            resetScores(countWin, countLost, games)
        raw_input("\n\tPress Enter to continue\n\n\n\n")

            
def main():
    playGame()
main()

Ive written this program and it works correctly until it get to the player playing another game against the computer
the loop does not work i think

Any help would be great

Thanks

if countLost == games:
            print com
            raw_input("Press Enter to exit")
            resetScores(countWin, countLost, games)
        raw_input("\n\tPress Enter to continue\n\n\n\n")

If I pressed enter with the last raw_input, nothing would have happened because their is no other command after that one.

I changed a few things (see the comments starting with #!!!) and added a loop. It seems to work, but there is still place for improvement.

from random import randint

def menu():
    
    while True:
        print """ \n\n\n\n\n\n\n
  ____   ___   ____ _  __   ____   _    ____  _____ ____  
 |  _ \ / _ \ / ___| |/ /  |  _ \ / \  |  _ \| ____|  _ \ 
 | |_) | | | | |   | ' /   | |_) / _ \ | |_) |  _| | |_) |
 |  _ <| |_| | |___| . \   |  __/ ___ \|  __/| |___|  _ < 
 |_| \_\\___/ \____|_|\_\  |_| /_/   \_\_|   |_____|_| \_\
                                                          
  ____   ____ ___ ____  ____   ___  ____  ____  
 / ___| / ___|_ _/ ___|/ ___| / _ \|  _ \/ ___| 
 \___ \| |    | |\___ \\___ \| | | | |_) \___ \ 
  ___) | |___ | | ___) |___) | |_| |  _ < ___) |
 |____/ \____|___|____/|____/ \___/|_| \_\____/\n\n"""
        MenuInput = int(raw_input("""     
    MENU
        1. Rock, Paper, Scissors 
        0. Exit

        Your Choice:  """))
       
        if MenuInput in range (2):
            break
        else:
            print "\n\tInvalid Entry"
    return MenuInput

def match(choice1, choice2):
    if choice1 == choice2:
        print "\tYou have a match, the computer wins."
        #raw_input("Press Enter to continue") #!!! we don't need this
    return choice1 == choice2 # !!! return True or False to allow "if match(...)"

#def resetScores(user, comScore, gamez): #!!! removed this, it won't work
#    user = 0
#    comScore = 0
#    gamez = 0

def firstChooserWins( chooserChoice, otherChoice ): 

    if chooserChoice == "Rock" and otherChoice == "Scissors":
        return True
    elif chooserChoice == "Paper" and otherChoice == "Rock":
        return True
    elif chooserChoice == "Scissors" and otherChoice == "Paper":
        return True
    else: 
        return False


def new(count, countL, game):
   
    if count == game:
        print "You win against the computer"
        return True
    elif countL == game:
        print "The Computer has beatin your ass"
        return True
    else:
        print "keep playing to win"
        return False

def same(a,b):
    if same(countWins, games):
        return False
    if same(countLost, games):
        return True

def showScores(countWins, countLost, totalGames, games):
    print "\tYou have Won: ",countWins
    print "\tComputer has Won: ",countLost
    print "\tTotal Games: ",totalGames
    print "\tFirst player to %d Wins! " %games
    
def playGame(): 
    choice = { 1:"Rock", 2:"Paper", 3:"Scissors" } 
    countWins = 0
    countLost = 0
    totalGames = countWins + countLost
    if totalGames > 0:
        return False
    com = "The Computer has won\nThe Computer has won\nThe Computer has won\n"
    you = "You have beatin the computer, congratulations\nYou have beatin the computer, congratulations\nYou have beatin the computer, congratulations\n"

   
    while menu() == 1:
        if totalGames == 0:
            userBestOf = int(raw_input("""
        How many games would you like to
        play best of with the computer? """)) #!!! changed float to int
        
        #Avg = userBestOf / 2
        games = (userBestOf + 1)/2
             
        print "\tFirst player to %d Wins! " %games
        
        while max(countWins, countLost) < games:
            showScores(countWins, countLost, totalGames, games)
            print max(countWins, countLost), games
            playerPick = int(raw_input(""" 
        Enter choice: 
        0 : Quit 
        1 : Rock 
        2 : Paper 
        3 : Scissors 

        Your choice : """))



            if playerPick == 0: 
                return

            if playerPick not in choice.keys(): 
                print "\tInvalid choice" 
                continue 

            playerChoice = choice[playerPick] 
            computerChoice = choice[randint(1,3)] 

            print "\tYou chose %s, the computer chose %s" % ( playerChoice, computerChoice ) 
        
            if firstChooserWins( playerChoice, computerChoice ): 
                print "\tYou have won this round!"
                countWins += 1
            elif match(playerChoice, computerChoice): #!!! moved this test
                countLost += 1
            else: 
                print "\tYou lose!"
                countLost += 1

            totalGames += 1


        # print "\tKeep playing, first to %d wins." % games #!!! we don't need this
        if countWins == games:
            print you
        else:
            print com
        countWin, countLost, games = 0, 0, 0
        raw_input("\n\tPress Enter to continue\n\n\n\n")

            
def main():
    playGame()
main()

Can you mark solved or tell what is still unclear/post results?

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.