Help with Print skipping Python

I’m making a Tower-of-Doom like game and while trying to fix the battles, despite there being a time.sleep(5) and text supposed to print, an entire print statement is not only skipped, but the code calculating effect is skipped. Not sure why this is happening.

https://replit.com/@jasecrowe/Tower-of-Doom-v101#main.py


userInput = input()
      if userInput.lower() == "str":
        print(f"""You chose a STRENGTH attack

{eCard}
Enemy Abilities:
Enemy Strength: {eCardStr}
Enemy Intelligence: {eCardInt}
Enemy Charisma: {eCardCha}
Enemy Health: {eHealth}""")
        if pCardStr > eCardStr:
          print("We win the battle.")
          eHealth -= pCardStr - eCardStr
          print(f"We dealt {pCardStr - eCardStr} damage.")
          time.sleep(5)

Hello,
could you clarify which print statement is skipped?

I would recommend using the builtin debugger to go through your code.
Place a breakpoint before the relevant section of code and step line by line to see what is happening.

Apologies
It’s everything after the if userInput.lower() == “str”: in the code snippet that’s inside the loop.

Found the issue. == and > statements for if userInput == “str”: weren’t done so it skipped it.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.