我继续收到error
消息,我感到难过,不知道如何修复它。
这就是我写的:
job = {'fireman': 42600, 'programmer': 48700, 'clerk': 23000}
salary = float(job * 1.05 ** years_of_service)
return salary
问题:
def salary(job, years_of_service):
'''(str, int) -> float
Return the salary (in dollars) of a person holding job for
years_of_service.
Each year, a person receives a 5% increase in salary over his/her previous
year. The starting salary for various jobs:
fireman $42 600
programmer $48 700
clerk $23 000
years_of_service will be at least 0.
>>> salary('clerk', 2)
25357.5
'''
答案 0 :(得分:1)
问题在于你试图乘以整个字典。你需要从dict获得起薪。由于这些方面的原因
salaries = {'fireman': 42600, 'programmer': 48700, 'clerk': 23000}
def salary(job, years_of_service):
return salaries[job] * (1.05 ** years_of_service)