Ask coding questions

← Back to all posts
Code not working but I can't find an issue
DAEMON816424 (8)


I am still working on this game and I keep getting error messages for the Attack Code (line 285, attackenemy() function). I have put the function in a separate repl and it works just fine.

Any idea why it won't work in my game repl?

Game repl is attached below.
Here's a link to the separate repl:

Answered by JULIODIAZ1 (47) [earned 5 cycles]
View Answer

on line 61 the variable num3 is representes as a string to conver it to a number you need to define it as

num3 = input("Third Number:")

global herolevel

herolevel = int(num3)

and you should do those to the rest of the num variables and i think that should fix it

DAEMON816424 (8)

@JULIODIAZ1 - Thanks, I did that for the code and it worked :)


happy to help although it took me like 10 mins to find the error. @DAEMON816424


on line 285, try using = insteas of ==.

DAEMON816424 (8)

@RYANTADIPARTHI - That does not work, it only returns an error message and underlines the code in red.