我已經在這幾個小時,尋找問題,甚至要求我的兄弟,誰是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