Ad
  • Default User Avatar

    the code also works fine in visual studio code, but does not work on when i test it on codewars

    this is a common expression but almost always seems to mean that you didn't do the same thing locally. use the same test case as what failed, make sure it's called correctly, or failing that, debug it in the codewars environment instead

    to clarify it is saying "found" has no value

    don't paraphrase error messages, because when you do then you can only relay the things you noticed about it which doesn't help when you're missing something about it. and "it is saying" - what entity is "it"?

    I'm guessing you mean:

    UnboundLocalError: cannot access local variable 'x' where it is not associated with a value

    here's a simple program with an obvious problem in it that produces that error message:

    def f():
        if x:
            pass
        x = 3
    
    f()