class Band: bandcount = 0 def __init__(self, name, instrument): #these are attributes self.name = name self.instrument = instrument Band.bandcount += 1 def displayInstrumnet(self): #this is a method print(self.name, "plays", self.instrument) def bandCount(self): print("# of Bandmembers = ", Band.bandcount)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter