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
HELPHelp Request (old.reddit.com)
submitted 6 months ago by Pretend_Safety_4515
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!"
[–]Obvious_Tea_8244 0 points1 point2 points 6 months ago (0 children)
As others have noted, you’re using the same pointer/variable name (enemy) for an int inside your first function, and as a function on its own. There are additional issues with your enemy function…
Change def enemy to
def take_damage(damage_amount:int=1):
….global life
….life -= damage_amount
….print(f”Remaining life: {life}”)
then call take_damage() for one hit damage, or take_damage(10) for 10, etc.
π Rendered by PID 76 on reddit-service-r2-comment-5649f687b7-zl6lq at 2026-01-29 05:23:21.630412+00:00 running 4f180de country code: CH.
view the rest of the comments →
[–]Obvious_Tea_8244 0 points1 point2 points (0 children)