2017-03-12 28 views
-3
if lead_x > randAppleX and lead_x < randAppleX + AppleThickness or lead_x + block_size > randAppleX and lead_x + block_size < randAppleX + AppleThickness: 
# print("x crossover") 
    if lead_y > randAppleY and lead_y < randAppleY + AppleThickness: 
# print("x and y crossover") 

    elif lead_y + block_size > randAppleY and lead_y + block_size < randAppleY + AppleThickness: 

IndentationError: expected an indented block 

有人看到錯誤嗎? 。請幫助:(Python中的IndentationError(pygame)

+1

取消對第二個print語句和下'elif'添加一條語句 – pushkin

+0

你到底做 – patrick

+0

我試圖做一個蛇?遊戲。 – MauroT03

回答

0

Python的規定,每塊至少包含一個聲明和評論都沒有聲明所以,這是錯誤的語法:

if lead_y > randAppleY and lead_y < randAppleY + AppleThickness: 
    # print("x and y crossover") 

爲了這個目的,使用無操作pass statement時你想如註釋掉單行塊:

if lead_y > randAppleY and lead_y < randAppleY + AppleThickness: 
    # print("x and y crossover") 
    pass