r/learnpython • u/rwmmir • Oct 07 '20
Classes in Python
Hey,
what is the best way to learn using classes in Python? Until now, I was using functions for almost every problem I had to solve, but I suppose it's more convenient to use classes when problems are more complex.
Thanks in advance!
324
Upvotes
3
u/LogisticAI Oct 08 '20
Putting “take_damage=0” sets the default amount of damage that the enemy object will take if you call the enemy.damage() method without any arguments. You override the default when you call the method with the argument. So “enemy.damage(20)” sets “take_damage=20”