回覆總數然後將其打印在輸出中的模塊化python有問題。幫一幫?return python
def main():
Monday = int(input("Enter the store sales for Monday: "))
Tuesday = int(input("Enter the store sales for Tuesday: "))
Wednesday = int(input("Enter the store sales for Wednesday: "))
Thursday = int(input("Enter the store sales for Thursday: "))
Friday = int(input("Enter the store sales or Friday: "))
total = totalSales()
print("the total sales for the week are:", total)
def totalSales(Monday, Tuesday, Wednesday, Thursday, Friday):
weeklyTotal = Monday + Tuesday + Wednesday + Thursday + Friday
return weeklyTotal
main()
錯誤消息:
Enter the store sales for Monday: 5
Enter the store sales for Tuesday: 4
Enter the store sales for Wednesday: 6
Enter the store sales for Thursday: 2
Enter the store sales or Friday: 8
Traceback (most recent call last):
File "so.py", line 16, in <module>
main()
File "so.py", line 8, in main
total = totalSales()
TypeError: totalSales() takes exactly 5 arguments (0 given)
也許,如果你說你的「麻煩」的性質,有人可以幫助你。 –
你還沒有指定你的問題是什麼。但我敢打賭,你面臨的主要問題是你沒有將所需的參數傳遞給'totalSales()'。看看你如何定義函數,並看看你是如何調用它。 – idjaw
即時嘗試將總銷售額中的所有銷售總額加起來,然後將其返回 – vtecjustkickedinyo