循环进行Python编码

如果用户不希望输入5名员工,我如何结束循环并直接列出员工信息和员工中的平均薪水?

def avgSalary(EmpWages):     “”“查找平均工资的函数”“”     #最初将合计设置为0     总数= 0;

# Iterating over array
for i in range(0, len(EmpWages)):
    # Accumulating value
    total += EmpWages[i];
# Finding and returning average
return (total / float(len(EmpWages)));

def printData(EmpNames,EmpWages):     “”“函数将员工姓名和工资打印到控制台”“”     #打印标题     print(“ \ n \ n%-20s%-20s \ n”%(“员工姓名”,“员工工资”));     #遍历数组     对于范围内的我(0,len(EmpNames)):         #印刷价值         print(“ \ n%-20s%-20.2f”%(EmpNames [i],EmpWages [i]));     #打印平均工资     print(“ \ n \ n平均工资:%.2f \ n \ n”%(avgSalary(EmpWages)));

def readData(EmpNames,EmpWages):     “”“从用户读取数据并存储在相应数组中的函数”“”

# Reading five employee's details
for i in range(1, 6):
    # Reading employee name
    name = input("\n Enter Employee Name or DONE to Finish: ");

    # Iterate till user enters a valid salary
    while True:
        try:
            # Reading employee wage
            wage = float(input("\n Enter Employee Salary or DONE to Finish: "));
            break;
        except:
            print("\n Invalid Value!!! \n");

    # Adding to arrays
    EmpNames.append(name);
    EmpWages.append(wage);

def main():     “”         读取员工姓名并找到平均工资的Python程序     “”     #包含名称的列表     EmpNames = [];

# List that holds wages
EmpWages = [];

# Reading names and wages from user
readData(EmpNames, EmpWages);

# Printing report
printData(EmpNames, EmpWages);

调用主函数

主要();