n=int(input())#次數
lst=[0,0,0]#KDA
reply=[0,"You have slain an enemie.","You have slain an enemie.","KILLING SPREE!","RAMPAGE~","UNSTOPPABLE!","DOMINATING!","GUALIKE!","LEGENDARY!"]#回報的選項
comb=0#連殺數
while n > 0 :
condition=input()#輸入狀態
if condition == "Get_Kill" :
lst[0]+=1
comb+=1
i=comb
print(reply[i])
elif condition == "Get_Assist" :
lst[2]+=1
else:
if comb < 3 :
print("You have been slained.")
else:
print("SHUTDOWN.")
lst[1]+=1
comb=0
n-=1
print("%d/%d/%d"%(lst[0],lst[1],lst[2]))
n=int(input())#次數
lst=[0,0,0]#KDA
reply=[0,"You have slain an enemie.","You have slain an enemie.","KILLING SPREE!","RAMPAGE~","UNSTOPPABLE!","DOMINATING!","GUALIKE!","LEGENDARY!"]#回報的選項
comb=0#連殺數
while n > 0 :
condition=input()#輸入狀態
if condition == "Get_Kill" :
lst[0]+=1
comb+=1
i=comb
print(reply[i]) <--- 2
elif condition == "Get_Assist" :
lst[2]+=1
else:
if comb < 3 :
print("You have been slained.")
else:
print("SHUTDOWN.")
lst[1]+=1
comb=0
n-=1 <--- 1
print("%d/%d/%d"%(lst[0],lst[1],lst[2]))
三個問題: (錯誤處我用<---標註)
一: 縮排問題
這裡要多一個Tab
二: 超出list範圍問題
LEGENDARY!是大於等於8,所以10, 11, 12也行,但你的寫法會超出範圍
三: 空格問題(這個比較是作者的問題)
測資後面被放了奇怪的空格,C沒問題,但python要strip()掉
最後附上修正後程式碼(確認AC請放心):
如果有什麼地方說錯請大大指正
n=int(input().strip())#次數
lst=[0,0,0]#KDA
reply=[0,"You have slain an enemie.","You have slain an enemie.","KILLING SPREE!","RAMPAGE~","UNSTOPPABLE!","DOMINATING!","GUALIKE!","LEGENDARY!"]#回報的選項
comb=0#連殺數
while n > 0 :
condition=input().strip()#輸入狀態
if condition == "Get_Kill" :
lst[0]+=1
comb+=1
i= comb if comb <= 8 else 8
print(reply[i])
elif condition == "Get_Assist" :
lst[2]+=1
else:
if comb < 3 :
print("You have been slained.")
else:
print("SHUTDOWN.")
lst[1]+=1
comb=0
n-=1
print("%d/%d/%d"%(lst[0],lst[1],lst[2]))