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()
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.
+ 1
line 4: __init__() instead of _init_() (double underscore)
line 7: there are two %s, but only one parameter (won't work)
+ 1
thanks