다음은 아래 표와 같은 내 코드입니다 :Elif 문 구문 오류 : 구문이 잘못 되었습니까?
menu= "Welcome to the menu\n" \
+ "Please select an option below:\n" \
+ ( "0 - Enter a number\n" + "1 - Display current number\n" + \
"2 - Divisibility checking\n" + "3 - Perfect checking\n" + \
"4 - Triangular checking\n" + "5 - Quit\n")
x == ("")
while option!=5: # <<< Q2
print(menu)
option= int(input("Enter option: "))
if option==0:
x= int(input("What is your number?: "))
while x <=0:
x= int(input("Must be positive, please! What is your number?: ")
elif option==1: # <<< Q1
print("The current number is", x)
elif (x == ""):
print("No number yet - Please input a number and try again.")
x= int(input("What is your number?: "))
Q1 : 내가 두 번째 elif
문, 내 코드의 line 14
에 대한 오류 메시지가 표시 유지하는 이유 궁금했다.
Q2 : I이었다 또한 내가 아직 옵션을 입력하도록 사용자에게 메시지가 표시되지 않았다면 처음 while
문, 그때 print
메뉴를 option!=5
은 "option
"를 정의하는 방법, 궁금.
이 두 가지 사례에 대한 도움은 정말 감사하겠습니다.
감사합니다.
코드를 읽었습니까? '엘프 '가 무엇인지 알고 있습니까? –
while 루프가 아무것도하지 않기 전에'elif (x == "")'''x == ("")'와 같은 elif 문을 중첩 할 수 없습니다. –
앞의 줄에있는'int()'괄호를 닫는 것을 잊었습니다. –