【发布时间】:2016-06-06 20:37:52
【问题描述】:
我不知道为什么我的美元总额无法正确打印。我只想将用户的输入乘以 0.73 并打印 usd_total。
我收到此错误:
usd_total = aus_to_us(us_exchange * aud_amount) 类型错误:aus_to_us() 缺少 1 个必需的位置参数:'aud'
def aus_to_us(exchange_rate, aud):
usdConversion = exchange_rate * aud
return usdConversion
aud_amount = float(input('Enter the amount in AUD: '))
us_exchange = 0.73
usd_total = aus_to_us(us_exchange * aud_amount)
print('The amount in USD is: ', usd_total)
【问题讨论】:
-
将函数参数的星号更改为逗号。
-
定义 “正确” 并详细说明它与当前结果的不同之处。
-
一般来说,你应该说明你想要什么结果,你得到什么“不正确”的结果。 (错误等)
-
我已经更改了描述
标签: python function arguments parameter-passing