I really can't see where the problem in my code is. The error I am getting is NameError: name 'display_string' is not defined
But I don't understand where it is coming from. If I remove the if/else from the function, I get no errors. Same if I replace it with a simple display_string = "something"
.
def show_table(self, rows = [], move = "none"):
display_string = ""
def display(value = ""):
global display_string
if value == "":
display_string += "\n"
else:
display_string += str(value)
Full traceback:
C:\Users\vip\Desktop\Python>python test.py
Traceback (most recent call last):
File "C:\Users\vip\Desktop\Python\test.py", line 257, in <module>
screen.addstr(obj.show_table(rows))
File "C:\Users\vip\Desktop\Python\test.py", line 197, in show_table
display()
File "C:\Users\vip\Desktop\Python\test.py", line 120, in display
display_string += "\n"
NameError: name 'display_string' is not defined
Can anyone help clearing things up?