Celebrity dogs game , i don't know why my code isnt working!

For school, I have to do this celebrity dogs game. unfortunately, coding is not my strongest point of computer science; I have used lots of sources to help me code this such as codecademy , stack overflow etc.

I am having some issues when I run the code I was wondering if anybody has any ideas.

#celebirty dogs game

import random #allows to randomly choose

menu = """
=======================
welcome to the celebrity dogs game
please choose an option
1 - begin game
2- quit
option : """

categorychoice = """

====================
please select a category you wish to compare/
1 - Excerise
2 - Friendliness
3 - Intelligence
4 - Drool
"""

x=0
a=o

cardchoice = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
multiple2 = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]

def NumberOfCards():
    NumberOfCards = int(input("please enter how many cards you would like to play with!(between 4 and 30 IT HAS TO BE EVEN"))
    if NumberOfCards >= 4 and NumberOfCards <=30 :
        print("value accepted")
    else:
        print("thats to low/high try again ill return you to the main menu and you can try again!")
        mainmenu()

def ListOfDogs():
    global dogs
    with open('dogs.txt') as dogname : #saves as variable cards
        dogs = dogs.reas().splitylines() #seperates them
        dogs = [line.split(",") for line in dogname] #splits the list

    return dogs

def BeginGame():
    playerpile = pilenumber/2
    computerpile = pilenumber/2

    while true:
        playerexcercise = random.randint(1,5) 
        playerintelligence = random.randint(1,100)
        playerfriendliness = random.randint(1,10)
        playerdrool = random.randint(1,10)
   
        computerexcercise = random.randint(1,5)
        cmputerintelligence = random.randint(1,100)
        ccomputerfriendliness = random.randint(1,10)
        computerdrool = random.randint(1,10)
        print("you have :",playerpile,"cards :)")
        print("the computer has:",computerpile,"cards :)")
        print("your dogs name is :")
        print(random.choice(dogs))
        print("(1) Excercise: ",playerexcercise)
        print("(2) Intelligence: ",playerintelligence)
        print("(3) friendliness: ",playerfriendliness)
        print("(4) Drool: ",playerdrool)
        y = 0

 while y == 0:
        print(categorychoice)

        category = int(input("please choose an option"))
    if category == 1 
        print("you have chosen to compare Excercise")
        print("player :", playerexcercise,)
        print("Computer: ",computerexcercise,".")
                if computerexcercise > playerexcercise:
                    print("aw no you lost the : computer wins!")
                    playerpile = playerpile - 1
                    computerpile = computerpile + 1
                    print(playerexcercise)
                    cardgeneration()
                    y = 1
                elif computerexcercise <= playerexcercise:
                    print("whooop you won : player wins!")
                    playerpile = playerpile + 1
                    computerpile = computerpile - 1
                    cardgeneration()
                    y = 1
    

     if category == 2:
        print("you have chosen to compare intelligence")
        print("player :", playerintelligence,)
        print("Computer: ",computerintelligence,".")
                if computerintelligence > playerintelligence:
                    print("aw no you lost the : computer wins!")
                    playerpile = playerpile - 1
                    computerpile = computerpile + 1
                    print(playerintelligence)
                    cardgeneration()
                    y = 1
                elif computerintelligence<= playerintelligence:
                    print("whooop you won : player wins!")
                    playerpile = playerpile + 1
                    computerpile = computerpile - 1
                    cardgeneration()
                    y = 1


     if category == 3:
        print("you have chosen to compare friendliness")
        print("player :", playerfriendliness,)
        print("Computer: ",computerfriendliness,".")
                if computerfriendliness> playerfriendliness:
                    print("aw no you lost the : computer wins!")
                    playerpile = playerpile - 1
                    computerpile = computerpile + 1
                    print(playerfriendliness)
                    cardgeneration()
                    y = 1
                elif computerfriendliness <= playerfriendliness:
                    print("whooop you won : player wins!")
                    playerpile = playerpile + 1
                    computerpile = computerpile - 1
                    cardgeneration()
                    y = 1


     if category == 4:
        print("you have chosen to compare drool")
        print("player :", playerdrool,)
        print("Computer: ",computerdrool,".")
                if computerdrool > playerdrool:
                    print("aw no you lost the : computer wins!")
                    playerpile = playerpile - 1
                    computerpile = computerpile + 1
                    print(playerdrool)
                    cardgeneration()
                    y = 1
                elif computerdrool <= playerdrool:
                    print("whooop you won : player wins!")
                    playerpile = playerpile + 1
                    computerpile = computerpile - 1
                    cardgeneration()
                    y = 1
    if playerpile == pilenumber:
                print("Player wins the game!")
                leave()
            elif computerpile == pilenumber:
                print("Computer wins the game!")
                leave()


def leave():
    
    while True:
        leave = int(input("""
    Would you like to:
    1 - Play Again
    2 - Leave Game
    Option:  """))
                
        if leave == 2:
          print("Please come again!")
          raise SystemExit #Stops the whole code
        elif leave == 1:
            print("""
            -----------------
            Returning to Menu
            -----------------
            """)
            menu1()

        else:
            print("Pleases select again.")

def menu1():
    while True:
        option = int(input(menu)) #Gives the user the option to leave or quit the game
        if option == 2:
            print("Goodbye, please come again!")
            raise SystemExit
        elif option == 1:
            pilenumber()
            cardgeneration()
            gamestart()
        else:
            print("Please select again.")


while True:
    menu1()
1 Like

This is a model I’ve derived of your main menu…

def pilenumber():
    pass
def cardgeneration():
    pass
def gamestart():
    print ("Started...")


def main():
    menu = """
Welcome to the Celebrity Dogs Game
  1 - Begin Game
  2 - Quit
> """
    def bye():
        print("Bye")
        raise SystemExit        
    def get_int():
        while True:
            x = input(menu)
            try:
                return int(x)
            except ValueError:
                print ("Try again...")
    def get_option():
        while True:
            option = get_int()
            if option == 2:
                bye()
            elif option == 1:
                pilenumber()
                cardgeneration()
                gamestart()
            else:
                print ("Try again...")
    get_option()

main()
==== RESTART: D:/cc/discuss/users/lucybrowning/celebrity_dogs_game.py ====

Welcome to the Celebrity Dogs Game
  1 - Begin Game
  2 - Quit
> 0
Try again...

Welcome to the Celebrity Dogs Game
  1 - Begin Game
  2 - Quit
> 1
Started...

Welcome to the Celebrity Dogs Game
  1 - Begin Game
  2 - Quit
> 2
Bye
>>> 

Wouldn’t suggest using it though, since we can see it posted here for the first time, unless your prof is willing to go along with it as attributed to this topic with a link in the footnotes.

We love to help teach coding around the world. Some teach by pressing us along, others by challenging examples. Pick up the details and dissemnate as best as possible whether in the learning environment or in the forums. So long as you know the forums are open minded and opinionated and solutions may not be as they appear, you’re half the way there.

2 Likes