2015-06-15 28 views
0
>>> x=5 
>>> y=10 
>>> if(x>y): 
... print 'x is greater': 
    File "<stdin>", line 2 
    print 'x is greater': 
     ^
IndentationError: expected an indented block 
+3

的錯誤信息是很清楚的...... – jonrsharpe

+0

u能請編輯代碼? –

+0

https://docs.python.org/2/tutorial/ – jonrsharpe

回答

0

錯誤消息說明了這一切。 Python使用縮進來處理塊,因爲你的print說法應該是if的塊中,應縮進:

>>> x=5 
>>> y=10 
>>> if(x>y): 
...  print 'x is greater': # Note the indentation here