我试图找到一种方法来解决这个语法错误。我似乎无法找到它使程序正常运行。 这是低于在python中的语法错误,需要项目帮助
wrong = 0
test = raw_input("Please enter a 4 digit integer:")
def start(test):
if test.isdigit():
if wrong(test)==True:
print 'Invalid input. Four integers must be entered.'
else:
numbers = []
for a in test:
digits.append(a)
a=calc(int(digits[0]))
b=calc(int(digits[1]))
c=calc(int(digits[2]))
d=calc(int(digits[3]))
code = str(c)+str(d)+str(a)+str(b)
print 'The encrypted integer is:',code
else:
print 'You input wrong. Use numbers only.'
def calc(num):
num+=7
num%=10
return num
def error(test):
if len(test)<4 or len(test)>4:
return True
else:
return False
start(test)
我的代码和固定是...
位数= 0 错= 0 测试的raw_input =( “请输入4位数的整数:”)
DEF开始(试验):
if test.isdigit():
if wrong(test)==True:
print 'Invalid input. Four integers must be entered.'
else:
numbers = []
for a in test:
digits.append(a)
a=calc(int(digits[0]))
b=calc(int(digits[1]))
c=calc(int(digits[2]))
d=calc(int(digits[3]))
code = str(c)+str(d)+str(a)+str(b)
print 'The encrypted integer is:',code
else:
print 'You input wrong. Use numbers only.'
DEF计算值(NUM): NUM + = 7 NUM%= 10 返回NUM
高清错误(测试):
if len(test)<4 or len(test)>4:
return True
else:
return False
开始(试)
不要让我们陷入悬念:错误是什么? – Malvolio 2011-04-26 04:42:48
请记住**显示您收到的错误消息**。我们无法从这里看到您的屏幕,所以我们必须猜测。如果我们猜错了,那么你浪费你的时间和我们的时间。 – 2011-04-26 04:43:24
好的,这是一个简单的错误,当我给他们打电话时没有正确命名。 – Pr0cl1v1ty 2011-04-26 05:02:42