This is a simple game coded in python the source code
and when run it in ubuntu 14.04
I've got this error
File "pong.py", line 18
self.canvas = canvas
^
IndentationError: expected an indented block
how can I solve it thanks
This is a simple game coded in python the source code
and when run it in ubuntu 14.04
I've got this error
File "pong.py", line 18
self.canvas = canvas
^
IndentationError: expected an indented block
how can I solve it thanks
In Python, the statements have to be indented by 4 spaces like this
def functionName():
//some stuff here
//other stuff here
Looking at the error, this might be the problem.
This question should be in Stackoverflow not in AskUbuntu. Please migrate this question there.
Apart from the above, it is a simple indentation error. You (or the coder) forgot to indent the lines in the function properly.
It should be like this:
Example: Lines 17-28
def init(self,canvas,color,paddle,paddle1):
self.canvas = canvas
self.paddle = paddle
self.paddle1 = paddle1
self.id = canvas.create_oval(10,10,25,25, fill=color)
self.canvas.move(self.id, 235,200)
starts = [-3,3]
random.shuffle(starts)
self.x = starts[0]
self.y = -3
self.canvas_height = self.canvas.winfo_height()
self.canvas_width = 500
Do similarly for the other functions as well.
def __init__(self,canvas,color,paddle,paddle1):
NOT def init(self,canvas,color,paddle,paddle1):
the autoformatting doesn't seem to show it.
def
keyword till you encounter a blank line. Do this for the entire document.