2016-11-15 24 views
0
print ("Hey there Aga!") 
print (" ") 
begin = input("would you like to begin?: ") 
if begin == "yes": 
print ("very well then, ill give you an easy question to find the password for the first folder..") 
print (" ") 
print ("A) Hajiko") 
print ("B) Hajika") 
print ("C) Hajima") 
q1 = input ("what was the noise my phone made when we lost it?") 
if q1 == 1 
print ("yeah boy") 

IM是這麼說的困惑我該怎麼辦LMAO,從字面上所有的說法是關於語法或縮進?if語句無效語法或意外縮進,我第一次使用Python(非常簡單的代碼)

+0

瞭解語法的基本知識。在'真正的'if語句中的所有內容都應該縮進。另外,最後一個如果最後缺少「:」。 – CamiloR

回答

0

縮進被用來定義的範圍,就像{}在C.你需要縮進要包含在每個if S的喜歡,所以一切:

print ("Hey there Aga!") 
print (" ") 
begin = input("would you like to begin?: ") 
if begin == "yes": 
    print ("very well then, ill give you an easy question to find the password for the first folder..") 
    print (" ") 
    print ("A) Hajiko") 
    print ("B) Hajika") 
    print ("C) Hajima") 
    q1 = input ("what was the noise my phone made when we lost it?") 
    if q1 == 1: 
    print ("yeah boy") 

注:第二if包含在第一個內部,所以它的內容必須縮進另一個層次。