Я пытаюсь создать систему управления сотрудниками и испытываю трудности с печатью всех элементов, внесенных в список, в указанном формате c. Я могу распечатать мою последнюю запись, но если у меня есть несколько элементов списка, они не будут отображаться на экране. Что я делаю неправильно в моем для l oop или есть лучший способ отобразить их все в указанном мною формате?
employee_info = [ ]
while True: # While loop created to make the script constantly run
counter = len(employee_info) # Counter created so that the user will know how many entries there are
print('There are', '(', (int(counter)), ')', 'employees in the system.\n')
add_new = input('Would you like to add a new employee to the system or view all employee entries in the system?\
To add an employee, type: "ADD". To view all employees currently in the system, type: "VIEW ALL."\n') #Added option to add an employee or to view all employees currently the system
if add_new == 'ADD':
while True: # Loop created to input employees with option to quit
employee_index = [input('Employee Name\n'), input('Employee SSN\n'), \
input('Employee Telephone Number ***Entered as (555)555-5555*** \n'), input('Employee Email\n'), input('Employee Salary ***Entered as $xxxx***\n')]
employee_info.append(employee_index)
more_employees = input('Would you like to add another employee? Y or N.\n')
if more_employees == 'Y':
continue
elif more_employees == 'N':
break
elif add_new == 'VIEW ALL':
for x in employee_info:
print(' -----------------', employee_index[0], '-----------------\n')
print('SSN:', employee_index[1], '\n')
print('Phone:', '(' + employee_index[2][0] + employee_index[2][1] + employee_index[2][2] + ')' + employee_index[2][3] + employee_index[2][4] + employee_index[2][
5] + '-' + employee_index[2][6] + employee_index[2][7] + employee_index[2][8] + employee_index[2][9], '\n')
print('Email:', employee_index[3], '\n')
print('Salary:', '$' + str(employee_index[4]), '\n')
print(' ----------------------------------------------------')