# Python – Need indicators on how to improve my game code. What would a professional do? Learn alone

``````randomly import

P_HEALTH = 100
E_HEALTH = random.randint (5, 40)
``````

potion function

``````def POTION ():
Global P_HEALTH
P_HEALTH = P_HEALTH + 5
if P_HEALTH> 100:
P_HEALTH = 100
``````

This function is when you fight a spider …

``````def spider ():
Global P_HEALTH
Global E_HEALTH
edmg = random.randint (1, 5)
pdmg = random.randint (5,15)
print (& # 39; & # 39; & # 39; & # 39; & # 39;
The spider strikes for {edmg} damage ". & # 39;)
P_HEALTH = P_HEALTH - edmg
if P_HEALTH <0:
P_HEALTH = 0
print (& # 39; & # 39; & # 39; & # 39; & # 39;
Your health is {P_HEALTH} & # 39; & # 39;)
print (& # 39; & # 39; & # 39; & # 39; & # 39;
You hit for {pdmg} damage. & # 39; & # 39; & # 39;)
E_HEALTH = E_HEALTH - pdmg
if E_HEALTH <0:
E_HEALTH = 0
print (& # 39; & # 39; & # 39; & # 39; & # 39;
The health of spiders is {E_HEALTH} & # 39; & # 39;)
``````

This section would be isolated in the game when you encounter a spider

``````while E_HEALTH> 0 and P_HEALTH> 0:
spider()
``````

It is at this moment that you find a potion. the code would be isolated.

``````print (& # 39; & # 39; & # 39; & # 39; & # 39;
Your health is {P_HEALTH} & # 39; & # 39;)
P_HEALTH = P_HEALTH
POTION()

print (& # 39; & # 39; & # 39; & # 39; & # 39;
You find a potion, your health is now {P_HEALTH} & # 39; & # 39;)
``````