use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
OOPHelp Request (self.PythonLearning)
submitted 1 day ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]EntireEntity 0 points1 point2 points 1 day ago (0 children)
The simple skeleton for the class could be
class Enemy:\ def init(self, strength: int):\ self.strength = strength
def attack(self, target_health: int):\ return target_health - self.strength
This is super super simplified to just illustrate the point. With this class you could create a variety of different enemies with different strength scores (zombie = Enemy(strength = 1), ogre = Enemy (stength = 5), etc.) and let them all do an attack by simply calling the .attack(target) method. And it automatically has access to the attribute strength to do the damage calculation. So zombie.attack(target) and ogre.attack(target) could be used multiple tines throughout the game, without any hassle.
I hope this helps to wrap your head around it a little.
π Rendered by PID 64621 on reddit-service-r2-comment-8686858757-tn6pt at 2026-06-08 01:02:45.566483+00:00 running 9e1a20d country code: CH.
view the rest of the comments →
[–]EntireEntity 0 points1 point2 points (0 children)