當我在python中運行此代碼時,它給了我一個語法錯誤,並突出顯示了我指出的行中的「l」。它爲什麼這樣做?Python語法錯誤
from Euler import primeSieve,sumDig
def powerSieve(n):
powers = []
primes = primeSieve(100)
for i in primes:
j = 2
while i ** j <= n:
for k in primes:
if i == k and i ** j >= 10: powers.append(i ** j)
else:
l = 1
while l * (i ** j) <= n:
if l * (i ** j) >= 10: powers.append(l * (i ** j)
##THIS LINE l *= k
j += 1
return sorted(set(powers))
from time import clock
start = clock()
print "Answer to PE119 = ",powerSieve(100)
elapsed = clock() - start
print elapsed * 1000,"ms"
這條線是如何縮進的? – utdemir
在決定發佈re:語法錯誤之前,您應該花更多時間處理代碼。 – Reno