私は給与の返品としてゼロを得る。私はそれが可変範囲と関係があるかもしれないことは知っていますが、私は迷っています。どのように私はwhileループで毎回累積するPythonで関数を作成しますか
'''
Write a program to declare two empty lists one is for name and one for salaries.
Within the for loop ask for employees name and their salaries
and append them into the list accordingly.
Find out the total salary using accumulation concept but you
need to call a function called EvaluateSalary() within the for loop passing the argument
salary for each iteration.
Output : Both of the lists with their items and the total salary.
'''
#Declare name list
nameList = []
#declare salary list
salaryList = []
#declare quit constant
QUIT = "ZZZ" or 000
employeeName = str(input("Please enter an Employee name or ZZZ to quit : ")).upper()
employeeSalary = float(input("Please enter the salary of the Employee or 000 to quit : "))
以下は正しく行われていないものです。私はそれがループの各パスを介して給与の入力を追加したい。
salary = 0
def EvaluateSalary(salary):
salary = salary + employeeSalary
return salary
while employeeName != QUIT:
nameList.append(employeeName)
salaryList.append(employeeSalary)
EvaluateSalary(salary)
employeeName = str(input("Please enter an Employee name or ZZZ to quit : ")).upper()
employeeSalary = float(input("Please enter the salary of the Employee or 000 to quit : "))
print("Goodbye!")
print(nameList, salaryList, salary)
、あなたのコードがそれはある – Pykler
を動作するように適切にインデントする必要があります。私はちょうどここに正しく投稿する方法を知りません –
それは自分のコードをフォーマットしていました –