TypeError:不支持*的操作数类型:“dict”和“float”

2024-06-14 15:18:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直收到那条消息,但是我被难住了,不知道如何修复它。

这是我写的:

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
'''

Tags: ofin消息forreturnservicejobfloat