사용자에게 8 자리 바코드를 입력 시키려합니다. 코드 길이가 8 자리가 아니면 오류 메시지를 인쇄합니다. 길이가 8 자리이면 오류가 발생합니다.이 코드가 들여 쓰기/구문 오류를 생성하는 이유
def get_user_input():
global total_price
""" get input from user """
while len(str(GTIN))!=8:
try:
GTIN = int(input("input your gtin-8 number:"))
if len(str(GTIN))!=8:
print("make sure the length of the barcode is 8")
else:
print("make sure you enter a valid number")
return GTIN
. 오류/스택 추적을 공유하십시오. –
이 함수 다음에 다음 줄에 알 수없는 들여 쓰기가 있습니다. – Yeas123
들여 쓰기가 올바르게되었는지 확인하십시오. 'while'은 주 실행 수준에 있기 때문에, get_user_input 내부에는 없습니다. 기능. – Ajean