Help with program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help with program?

So is there something I could add to this class that will print “name” is a “personality” without having to do the print commands I have at the bottom? https://code.sololearn.com/c6WnsWAGDbIN/?ref=app

15th Jul 2020, 12:23 AM
Blake Haynes
1 Answer
+ 1
Yes!! You can add a method to the class, let's say introduce class Dog: def __init__(...): ... def introduce(self): print(self.name, ' is ', self.personality) and then call it on every object
15th Jul 2020, 12:37 AM
Ali Abdelhady
Ali Abdelhady - avatar