Ask coding questions

← Back to all posts
Why does it think i didnt assign the variable?
eh506249 (3)

it says the variable is referenced before its assigned but i assign it on line 15. why is it saying this?

Answered by robowolf (550) [earned 5 cycles]
View Answer
Comments
hotnewtop
robowolf (550)

In combat put global crit this makes sure it references the global variable crit.

OscarSowerbutts (9)

I don't really know but maybe define crit somewhere else????

VulcanWM (2586)

You cannot use the variable you assigned outside the function inside the function by what I know.
Try doing the code below by assigning the variable in the function:

def combat(enemy_number, crit):