我在与我的这部分代码的问题:
蟒蛇 - 打破嵌套条件的原始圈顶部
if(input not in status_list):
print("Invalid Entry, try again.")
break
断裂退出整个程序,我只是想回去程序(至的开始,而(1):)
我试图通,继续回想不出别的..谁能帮助? 谢谢:)
此外它阅读本浮动收入为字符串仍然..:income = int(input("Enter taxable income: "))
该错误消息我得到的是“类型错误:‘海峡’对象不是可调用的”
import subprocess
status_list = ["s","mj","ms","h"]
while(1):
print ("\nCompute income tax: \n")
print ("Status' are formatted as: ")
print ("s = single \n mj = married and filing jointly \n ms = married and filing seperately \n h = head of household \n q = quit\n")
input = input("Enter status: ")
if(input == 'q'):
print("Quitting program.")
break
if(input not in status_list):
print("Invalid Entry, try again.")
break
income = int(input("Enter taxable income: "))
income.replace("$","")
income.replace(",","")
#passing input to perl files
if(input == 's'):
subprocess.call("single.pl")
elif(input == 'mj'):
subprocess.call("mj.pl", income)
elif(input == 'ms'):
subprocess.call("ms.pl", income)
else:
subprocess.call("head.pl", income)
风格上,应避免周围的条件括号你的'if's和'while's(即'while 1:'而不是'while(1):','如果输入=='s':'而不是'if(input =='s') :'......) – nneonneo 2013-02-28 20:14:27
'continue'应该按照你想要的来做。 – 2013-02-28 20:15:42
很难理解'继续'是如何失败的 – cnicutar 2013-02-28 20:15:45