pretty new to learning python and wanted to give myself a challenge, but have ran into an issue where i cannot get my numbers to change. If I subtract a number from it then subtract another number from it again on a different line of code it does not update from the original number. what i need is something that will do this: a = 100 b- 20 a- b =80 a - b =60 hopefully this makes some sense :)
def viper_battle():
print("viper has the first attack,")
while player_health >= 1 or viper_health >= 1:
viper_atk = random.choice(viper_turn_list)
if viper_atk == 1:
print("viper has attacked you leaving you at", player_health - viper_dmg, "health")
elif viper_atk == 2:
print("viper is performing ship repairs only dealing half damage to you")
elif viper_atk == 3:
print("oh no viper used a special allowing them to deal the same damage as the health they have leaving us at", player_health - viper_special)
if player_health <= 0:
print("you lost!")
sys.exit()
attack_1 = input("what is your move: ")
if attack_1 == "a" or attack_1 == "A":
print("Direct hit!", viper_health - player_base_dmg, "health remains of our enemy")
elif attack_1 == "s" or attack_1 == "S":
print("The swarm was set upon Viper dealing massive damage", viper_health - player_special,"health remains of our enemy")
elif attack_1 == "r" or attack_1 == "R":
print("repairs were made tou our ship", player_health + player_repair)
elif attack_1 == "d" or attack_1 == "D":
print("we could not handle the heat, we retreated successfully")
sys.exit
if viper_health <= 0:
print("we won this battle!")
sys.exit()
a = 100, b = 20, a-b =80
when you say a-b = 80 that is just a calculation (we would call that an expression). It doesn't change the value of a
or b
or anything else. You meed to assign your result to something you can use.
a = 100
b = 20
a = a - b # 80
a = a - b # 60