On 13/10/17 13:04, Chris Coleman wrote:
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):
You need a space between the `def` and the `__init__`.
^
SyntaxError: invalid syntax
what am i doing or not doing that is causing this?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor