kannoli
kannoli

Reputation: 378

Python, Expected an indented block? One complication

I'm trying to make a quick text based hockey team management game, but whenever I reference one of my functions I get 'expected an indented block'. Not sure if I'm stupid and can't find my mistake or something.

    def startup():
        print "Welcome to the Text Based Hockey League!"
        print "You will be tasked with being a team's General Manager"
        yourTeam = raw_input()
    class tbhl:
        def __init__(self):
            self.teamList["Mustangs", "Wolves", "Indians", "Tigers", "Bears", "Eagles", yourTeam]
    class game:
        def __init__(self, homeScore, awayScore):
            #games left in a team class

startup() #<-The line that the error points to
tbhl = tbhl()
print tbhl.teamList[7]

Upvotes: 3

Views: 110

Answers (1)

BlackVegetable
BlackVegetable

Reputation: 13054

When you have a commented out block as your only code for a function, use the keyword pass as well to prevent this error. Any code block that starts a new line of indentation cannot be left blank (or with only comments.)

...
class game:
    def __init__(self, homeScore, awayScore):
        #games left in a team class
        pass

pass is a no-op that will please the compiler when it looks for something at that indentation level.

Upvotes: 7

Related Questions