0

Please solve this

import os os.system("clear") class Board(): def _init_ (self): self.cell=[ " "," "] def dysplay(self): print(" |%s|%s" %(self.cell[1])) board = Board() board.dysplay()

11th Oct 2018, 5:04 PM
aman singh
aman singh - avatar
3 Réponses
+ 4
first off, please include more info about what you're struggling with! not many want to try and fix your code with no info. when you see errors you should try and look them up too. second, your init needs two _ , like __init__ not _init_ that's kind of a silly mistake, I've made it too before. Python just loves two _ third, on dysplay you need to add the second argument, as it only has one. like print("|%s|%s"%(self.cell[0],self.cell[1])) which by the way, lists start at 0, not 1. after that the code should work. though it displays nothing but two spaces, as that's what you set the cells as.
11th Oct 2018, 5:59 PM
Ahri Fox
Ahri Fox - avatar
+ 1
line 4: __init__() instead of _init_() (double underscore) line 7: there are two %s, but only one parameter (won't work)
11th Oct 2018, 5:53 PM
Anna
Anna - avatar
+ 1
thanks
11th Oct 2018, 11:01 PM
aman singh
aman singh - avatar