[Tutor] problem with program

Chris Coleman anrkris at gmail.com
Fri Oct 13 08:04:56 EDT 2017


just learning python as my first programming language.  going through the
book "python in easy steps" by mike mcgrath.  i am going through the
programs in chapter 7 and can't get them to work.  here is the first one in
the chapter:
class Bird:
    '''A base class to define bird properties.'''
    count=0
    def_init_(self,chat):
        self.sound=chat
        Bird.count+=1
    def talk(self):
        return self.sound
from Bird import*
print('\nClass Instances Of:\n',Bird._doc_)
polly=Bird('Squawk,squawk!')
print('\nNumber Of Birds:',polly.count)
print('Polly Says:',polly.talk())
harry=Bird('Tweet,tweet!')
print('\nNumber Of Birds:',harry.count)
print('Harry Says:',harry.talk())

i am getting this error message:

File "scripts/bird.py", line 4
    def_init_(self,chat):
                              ^
SyntaxError: invalid syntax

what am i doing or not doing that is causing this?


More information about the Tutor mailing list