The Function to Write In this part of the assignment, you will write a function
ID: 3726184 • Letter: T
Question
The Function to Write In this part of the assignment, you will write a function find employee (, which takes three arguments, in this order . employees: A list of lists, in which each sub-list contains information about one particular employee Inside each sub-list we always find five tuples, wherein each tuple has two values: the first value is a field name, and the second value is the value of that field The fields available are listed below. Note that although the five tuples will always exist, their order inside the sub-list may differ from employee to employee o 'Name': this string is the employee's name o 'Age': this integer is the employee's age o 'Salary: this integer is the employee's salary o Experience': this integer is the years of experience the employee has o 'Level' this integer is the employee's rank An example employees list containing the information about two employees is given below: employees[ [ , Name, , , Tom., , ('Age, , 21) , ('salary, , [(*Experience', 2, (*Age', 22),Explanation / Answer
def find_employee(employees, search_field, search_value): lst = [] for employee in employees: name = '' for field in employee: if field[0] == 'Name': name = field[1] break for field in employee: if field[0] == search_field and field[1] == search_value: lst.append(name) break return lst
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.