Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Can't find error in code but Python throws exception
#1
Hello-

I'm making a text-based RPG with Python, but when I run my script, Python throws an exception. I've narrowed down the place of error to the following:

str = 1
spd = 1
#First combat
print("Outside is a large spider. You engage it in combat.")
enemyhp = 1
enemyspeed = 0
print("The enemy's HP is ",enemyhp1,", and its speed is ",enemyspeed,".")
attack = input("Do you FLEE or FIGHT?")
#Fight...
if attack == "FIGHT":
	damagedealt = 2*str
	print("You slash it, dealing ",damagedealt," damage.")
	enemyhp1 = enemyhp1 - damagedealt
	print("The enemy's HP is now at ",enemyhp1,". It dies. You also gain 2 XP from killing it, putting you at 2.")
	xp = 2
#...or flight.
if attack == "FLEE" and enemyspeed < speed:
	print("You succesfully fled the enemy. You can only flee when your speed is greater than the enemy's, and it gives you half as much XP. You are now at 1 XP.")
	xp = 1
It's supposed to give a choice between fighting or fleeing. When one attacks it deals damage in accordance with the strength of the character, or if one flees and your speed is greater than the enemy's you escape it. There seem to be no errors, but if someone can look it over for me and point out one, I'd be very grateful.

Thanks!
Quote

Top Page

Messages In This Thread
Can't find error in code but Python throws exception - by Sandwich_masterX - Oct-09-2018, 12:27 AM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple python code error cls0724 5 288 Mar-12-2020, 07:45 PM
Last Post: stullis
  Exception: Returned Type Mismatch Error devansing 1 114 Mar-06-2020, 07:26 PM
Last Post: ndc85430
  Error in python code 'import callbot' Lou_Reed 3 211 Jan-07-2020, 09:33 PM
Last Post: Clunk_Head
  Continuing code after exception palladium 1 189 Dec-14-2019, 02:43 PM
Last Post: ichabod801
  i am getting error while writing code for exception logging rkgupta51179 1 208 Nov-03-2019, 05:12 AM
Last Post: buran
  How to fix 'uncaught exception of type NSException' in Python MonsterPython 0 318 Jul-09-2019, 06:52 AM
Last Post: MonsterPython
  problem using custom exception handling in python srm 3 412 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  Can you find the problem in my code? ivinjjunior 3 405 Apr-20-2019, 12:37 AM
Last Post: ivinjjunior
  How to fix error code 2 in python, “directory not found”? dav3javu 1 605 Apr-03-2019, 04:55 PM
Last Post: Larz60+
  Indentation error in Python code ErnestTBass 5 716 Feb-28-2019, 04:26 PM
Last Post: samsonite

Forum Jump:


Users browsing this thread: 1 Guest(s)