所以當我運行這個腳本時,它一直說'銷售未定義'。我只是錯過了一些明顯的東西?我是python的新手。爲了更具體一些,它說明了我們'上市(銷售,所有者)'的問題。我感謝任何幫助我的人,我希望你有愉快的一天。在一個函數定義Python 3 - 爲什麼這個變量沒有在這個函數中定義
def launch():
sales = [0] * 7
sales[0] = float(125900)
sales[1] = float(115000)
sales[2] = float(105900)
sales[3] = float(85000)
sales[4] = float(150000)
sales[5] = float(155249)
sales[6] = float(97500)
owner = [0] * 7
owner[0] = "Carson"
owner[1] = "Smith"
owner[2] = "Jackson"
owner[3] = "Swanson"
owner[4] = "Perry"
owner[5] = "Beufort"
owner[6] = "Anderson"
return sales, owner
def listing(sales, owner):
count = 0
count2 = 1
while count < 7:
print(count2 , "" , ":" , "" , "owner[count]\t" , "$" , "" , format(sales[count],',.2f'))
count = count + 1
count2 = count2 + 1
def main():
print("Welcome to the Botany Bay home sales calculator")
print("This program will calculate the average selling price of the homes")
print("sold this past year. It will then determine how many homes sold")
print("above the average and how many homes sold below the average.")
print("=======================================================================")
print("")
print("Botany Bay Home Sales")
print("*********************************")
listing(sales, owner)
launch()
main()