如何在python中显示函数的输出?

问题描述 投票:0回答:1

我正在尝试制作一个简单的转换程序,但输出总是奇怪或根本不出来。我该如何解决?这是我的代码。

#crypto = [Bitcoin, Ethereum, XRP, Litecoin]
bitcoin = [1, 40.19, 38284.22, 168.73]
ethereum = [.025, 1, 951.99, 4.20]
xrp = [.000026, .001, 1, .003]
litecoin = [.0058, .231, 223.81, 1]

def crypto2Crypto(x,y,w):
    if(x == "BE"):
        w =+ (y * bitcoin[1])
    if(x == "XL"):
        y * xrp[3]
    if(x == "EB"):
        y * ethereum[0]
    if(x == "LX"):
        y * litecoin[2]

def main():
    print("Welcome to the Cryptocurrency exchange!")
    conversion = input('"What will you be converting today? B = Bitcoin, E = Ethereum, X = XRP, Litecoin = L. Please give an exchange with the following syntax crypto1crypto2, ex. type "BE" for Bitcoin to Ethereum."')
    amountOfCurrency = float(input("How much do you have of " + conversion[0] + " ?"))
    w = crypto2Crypto(conversion,amountOfCurrency,0)
    print(w)
main()
python function numbers output
1个回答
-1
投票

将其附加到crypto2Crypto函数的末尾

return w 

不确定w是否是您需要的,但返回您需要的东西

© www.soinside.com 2019 - 2024. All rights reserved.