May-13-2023, 08:47 PM
Hello, in a program i have a class like this one but when in run the code i get that x is not defined, is this problem relative to list comprehension?
class MyClass: x = 8 y = 9 grid = [[0 for _ in range(x)] for _ in range(y)]
Error:Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<input>", line 4, in MyClass
File "<input>", line 4, in <listcomp>
NameError: name 'x' is not defined