Dec-18-2018, 04:11 PM
Hi all, I´m trying to make a method __str__ for my class. It should have just one line (return ...) as usually this method is supposed to look like, and it should create a string from two dimensional list. List contains 9 lines, each with 9 items (items can be "." or number 1-9) separated by a space. What do I have so far is this:
def __str__(self): my_str = "" for line in self.tab: for item in range(len(line)): my_str += str(line[item]) + " " my_str += "\n" return my_strAs you can see, this takes many lines, but it should be just in one. Can you help me with that? Thanks.