user4966102
user4966102

Reputation:

Calling a function not working

I have my blackjack game working great (first project, still a beginner). But to keep looping once the game is finished I now need to implement functions and classes I think.

Without copying over all of my code, this is the skeleton of my project so far. I split it into two functions because I think it just makes it a little neater... but if I shouldn't do that, let me know.

(couple of imports)
(couple of variables declared)

class Game:

    def newGame(self):
        (code)
        (Game.choices)
    def choices(self):
        (code)
        (Game.newGame)

Game.newGame()

Shouldn't this call the first function, which will in turn call the second function?

Upvotes: 0

Views: 65

Answers (1)

AlG
AlG

Reputation: 15157

newGame needs an object before it can be called (that's why self is a parameter) do this:

x = Game()
x.newGame()

or (as was pointed out in the comments):

Game().newGame() 

Upvotes: 1

Related Questions