[英]My Python if-else statements are not working and i can't figure out why
第一個 elif 語句顯示無效的語法錯誤
N = int(input())
arr = []
for i in range(0,N):
inp = list(map(str,input().split()))
if inp[0] == 'insert' :
arr.insert(int(inp[1]),int(inp[2])
if (inp[0] == 'print'):
print(arr)
if inp[0] == 'remove' :
arr.remove(int(inp[1]))
您在第 7 行中缺少一個結尾)
。 這應該是:
arr.insert(int(inp[1]),int(inp[2]))
^
在 IDE 中使用 linter 來標記這些錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.