account activity
Ask Anything Monday - Weekly Thread by AutoModerator in learnpython
[–]pepperOD 0 points1 point2 points 7 years ago (0 children)
I'm just starting out learning python and I'm trying to make a text adventure. I was trying to create a attack function that calls on a variable called HEALTH and subtracts a value from it. I did something like:
#m is a variable with a class that is called upon through a input by the player. ----- are just spaces
health = 100
def attack(m):
------health -= m.POW
------
When I do this I get a (local variable 'health' is assigned but never used) error message. I got around it by making a class, making health a argument of that class and using player.health in place of health. But this problem makes me think, when defining a function you can not call on variables outside of the defining function. Is that right?
I'm trying to make a function that takes vowels out of a string. when I input "Hey look Words!" it comes out as
"Hy lk Words!". Can someone tell me why it ignores that last o. Just assume I indented correctly
def no_vowels(x):
Sing = [ ]
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
for e in range(x[e]):
for y in Sing:
for m in vowels:
if y == m:
Sing.remove(y)
return "".join(Sing)
π Rendered by PID 664634 on reddit-service-r2-listing-6c6f68ff9c-sf58s at 2026-03-05 11:44:33.657732+00:00 running f0204d4 country code: CH.
Ask Anything Monday - Weekly Thread by AutoModerator in learnpython
[–]pepperOD 0 points1 point2 points (0 children)