while True:
n1 = int(input("Enter first number: "))
if n1>255:
print("Invalid input. Sorry the number should be less than 255.")
continue
elif n1<255:
print("The input is valid.")
n2 = int(input("Enter second number: "))
if n2>255:
print("Invalid input. Sorry the second number should be less than 255.")
continue
elif n2<255:
print("The input is valid.")
break
每當我輸入高於255的'n2'時,它顯示輸入第一個數字。我想讓它顯示輸入第二個數字。如何在Python中使用和調試條件語句?
你還沒有想出如何正確使用while,continue和break。你可以輕鬆地教你自己,多玩一點。 –
請更改標題以便描述您的問題並且不要使用圖像。 – ayhan
這也可能對你有幫助 https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops – Altoyyr