我已经在这几个小时,寻找问题,甚至要求我的兄弟,谁是EE的高级,甚至他被难倒了。这是在午夜前的一个项目,我似乎无法摆脱这个错误。任何人都可以看看我的代码,并找出为什么我一直得到这个错误?谢谢,是的,它们在while语句下面正确缩进。Python3虽然语法错误
# Initialize Variables
count = 0
#First Customer Input
cus = input("Enter customer's name: ")
custype = input("Enter customer's service type (R for Residential. B for Business): ")
location = input("Enter customer's service location (C for City. P for Parish): ")
kwh = eval(input("Enter customer's number of Kilowatt Hours Used: ")
#Repeat loop based on input items NOT being the sentinel value
while (count < 10):
if custype == 'R' and location1 == 'C':
rate = residentialCity
elif custype == 'R' and location1 == 'P':
rate = residentialParish
elif custype == 'B' and location1 == 'C' or 'P':
rate = business
你能编辑你的文章以包含代码中的确切缩进吗? Python对它很挑剔。它确实看起来像是缺少'kwh = eval(input ...'行中的右括号,这是一个非常糟糕的想法BTW。 –
您的代码未被格式化为代码显示(我们已经为您修复了它)要正确地格式化代码,选择它并点击'{}'图标,或者缩进4列 –
@ D.Shawley是对的如果你想输入一个数字,使用'int(input(...))'或'float(input(...))'。有一个原因是Python在3.0中摆脱了自动评估的输入函数,不要把它带回来 – abarnert