0
class Stats:
    def __init__(
        self,
        hp,
        hunger,
        dehydration,
        phys_strength,
        mental_strength,
        psychic_powers,
        intelligence,
    ):
        self.hp = hp
        self.hunger = hunger
        self.dehydration = dehydration
        self.phys_strength = phys_strength
        self.mental_strength = mental_strength
        self.psychic_powers = psychic_powers
        self.intelligence = intelligence
        # hunger, dehydration, phys_strength, mental strength, and intelligence may decrease.


hero_stats = Stats(
    hp=50,
    hunger=10,
    dehydration=10,
    phys_strength=10,
    mental_strength=20,
    psychic_powers=0,
    intelligence=20,
)

hp_info = f"Your health point level is {hero_stats.hp}. Your HP caps out at 100, and you die when it reaches 0.\n\n"

I am unable to run this code in Sublime Text. I do not know why it does not work. It works from Terminal, but not from Sublime Text. Why? Also, I am using SublimeREPL for this.

Caspian Ahlberg
  • 934
  • 10
  • 19
  • 2
    Your sublime and Terminal might be using different versions of Python. `f-string` works only in python 3.7 – Sociopath Sep 25 '19 at 12:51
  • 1
    Sublime executes python scripts by executing `python`, but on many systems that will be Python 2, and you need to do something like `python3` to get version 3. The easiest diagnostic is to add `import sys; print(sys.version)` to a sample file and run it both ways and see what pops out. Most likely you need to customize the Python build to run the correct version. – OdatNurd Sep 27 '19 at 15:44

0 Answers0