最近看到python的循环语句,其中有个例子就是“利用while-else寻找10-20中数字的最大公约数问题”,书中代码如下,实际运行时多次报错,求助各位高手,貌似缩进有问题,就是改不对啊:L
#!/usr/bin/env python
def showMaxFactor(num):
count = num / 2
while count > 1:
if (num % count == 0): break
print 'largest factor of %d is %d' % \
(num, count)
break
count = count - 1
else:
print eachNum, 'is prime'
File "for eachNum in range(10, 21):<pyshell#0>", line 7 print 'largest factor of %d is %d' % \ ^IndentationError: unexpected indent