Day 028 - Project 28 : Battle Time

Every round you are making new strength stats which is why it’s unpredictable.

To see that this is what’s happening try changing it to

def battle_damage():
  strength_stats1 = strength_stats()
  print("strength stats 1", strength_stats1)#show that it's changing everytime
  strength_stats2 = strength_stats()
  print("strength stats 2", strength_stats2)#show that it's changing everytime
  battle_damage = abs(strength_stats1 - strength_stats2) + 1
  return battle_damage

To fix this you can just move

strength_stats1 = strength_stats()
strength_stats2 = strength_stats()

outside of def battle_damage(): so that they are set once and remain the same throughout the game.

strength_stats1 = strength_stats()
strength_stats2 = strength_stats()
def battle_damage():
  print("strength stats 1", strength_stats1)#comment out  or remove if unwanted
  print("strength stats 2", strength_stats2)#comment out or remove if unwanted
  battle_damage = abs(strength_stats1 - strength_stats2) + 1
  return battle_damage

image

1 Like

Why is this so hard :face_holding_back_tears: