간단한 인쇄 변수 줄을 프로그램에 추가하면 IndentationError가 발생합니다. 코드는 그림과 같이 주석 "예를 인쇄"라인과 함께 작동하지만 내가 주석을 해제 할 때 나는 오류 얻을 :들여 쓰기 오류 : 예기치 않은 들여 쓰기 : 문제가있는 명령을 인쇄하십시오.
이가 오류 :
이factors.append(yes)
^
IndentationError: unexpected indent
이 코드 :
이n = 1
x = int(raw_input("What is the number you would like largest prime factor of?"))
factors= []
checklist = []
primefactors = []
while n < (x+1)/2:
if x % n == 0:
yes = n
#print yes
factors.append(yes)
if n % 1000 == 0:
print "running n count = %s" % (n)
n += 1
for j in factors:
checklist = [j]
for i in range(2, j):
if j % i == 0:
checklist.append(j/i)
if len(checklist) == 1:
primefactors.append(checklist)
print "All factors of %s are %s" % (x,factors)
print "The prime factors are %s" % (primefactors)
print "The highest prime factor is %s" % (max(primefactors))
당신은 혼합되는 탭과 공간 님의
변경이 다음
if
블록을 변경합니다. 그러지 마. * 하나의 스타일 *, 바람직하게는 공백 *에만 붙이십시오. 파이썬은 탭을 다음 8 번째 열로 확장하지만 대신 탭을 구성하여 4 번째 열로 확장하는 것처럼 보입니다. –그게 다야, 지금 일하고있어, 고마워. – FinnPegler