我的第二個else語句拋出語法錯誤,爲什麼?else:聲明語法錯誤,簡單的Python
這是用於檢查sideswap數字代碼:
number1 = int(input("Enter a number between 0 and 9"))
number2 = int(input("Enter a number between 0 and 9"))
number3 = int(input("Enter a number between 0 and 9"))
X = number1 + number2 + number3
while True:
if X%3 !=0:
print("Not a valid sideswap number")
number1 = int(input("Enter a number between 0 and 9"))
number2 = int(input("Enter a number between 0 and 9"))
number3 = int(input("Enter a number between 0 and 9"))
else:
if number2 - number3 == 1:
print("Not a valid sideswap number")
number1 = int(input("Enter a number between 0 and 9"))
number2 = int(input("Enter a number between 0 and 9"))
number3 = int(input("Enter a number between 0 and 9"))
else:
if number3 - number1 == 1:
print("Not a valid sideswap number")
number1 = int(input("Enter a number between 0 and 9"))
number2 = int(input("Enter a number between 0 and 9"))
number3 = int(input("Enter a number between 0 and 9"))
else:
if number1 - number2 == 1:
print("Not a valid sideswap number")
number1 = int(input("Enter a number between 0 and 9"))
number2 = int(input("Enter a number between 0 and 9"))
number3 = int(input("Enter a number between 0 and 9"))