我正在研究employees
中的pay raise
,特别是ids
.假设我的公司有5
名员工.我在employee_id_list
中展示了它们.我想让python从我这里获取信息,包括employees
人中的ids
人,我想提高工资,以及他们的salary
人.然后,我从这些输入中创建dictionary
.现在我想迭代employee_id_list
,使其与input ids
匹配.如果匹配的话,我想分别取value of key
和salary
,并提高工资.但我犯了个错误.
employee_id_list = [27, 25, 98, 78, 66]
employee_dict = dict()
while True:
x = input("Enter an key to continue and 'r' for result: ").lower()
if x== 'r':
break
try:
employee_id = int(input("Enter key the Employee id: "))
salary = int(input(f"Enter the {employee_id}'s salary: "))
employee_dict[employee_id] = salary
except ValueError:
print("Please Enter the Integers!")
continue
print(employee_dict)
for e_ids in employee_id_list:
for key, value in employee_dict.items():
if e_ids in employee_dict[key] :
employee_dict[value] = 0.8*value + value
print(employee_dict)
我犯了这个错误
TypeError: argument of type 'int' is not iterable