Converting globals to class
<p>I have been using global variables for a little text game in python and have come across a lot of articles saying that global variables are a no no in python. I have been trying to understand how to get what I have below (just a health variable and being able to change it and print it) working using classes but I am confused how I can converted something like this in a class. Any help, example, point in the right direction would be great.</p>

<p>Here is an example of me using variables.</p>

<pre><code>import sys
import time

health = 100
b = 1

def intro():
    print("You will die after two moves")


def exittro():
    time.sleep(1)
    print("Thanks for playing!")
    sys.exit()


def move():
    global health
    global b
    health -= 50

    if health &lt;= 51 and b &gt;0:
        print("almost dead")
        b = b - 1


def death():
    if health == 0 or health &lt;= 0:
        print("...")
        time.sleep(1)
        print("You died\n")
        time.sleep(2)
        print("Dont worry, this game sucks anyway\n")
        exittro()

intro()

a = 1

while a == 1:
    input("Press Enter to move")
    move()
    death()
</code></pre>

<p>Thank you</p>

<p>Edit: this is the kind of thing I have been trying to do...</p>

<pre><code>class Test:
def __init__(self):
    number = 100

def __call__(self):
    return number

def reduceNum(self):
    number -=10

def printNum(self):
    print(number)

a = 1
while a == 1:
    input("Enter")
    Test.self.reduceNum()
    Test.self.printNum()
</code></pre>