python - Python-货币转换器不是实时的
解决方案
您以错误的方式输入货币。替换为以下代码:
amount = int(input("Please enter an amount to convert"))
if con=='a':
print(amount,'converts to ',amount*0.57)
此外,要添加更多货币类型,而不是输入所有内容,只需将它们以这种方式放入数组中:
currencies = [['CAD','GBP'],['CAD','USD'],['CAD','JPY'],['CAD','EUR']]
for i in range(len(currencies)):
print(i+1,' ',currencies[i][0],' to' ,currencies[i][1])
#change alphabet to integers
con = int(input("Please select the type of conversion"))
if con == 1:
print(amount,' ',currencies[i-1][0], converts to ',currencies[i-1][1],amount*0.57)
推荐阅读
- php - PDO:: fetch_assoc 和 fetch_object 区别 & 何时最好使用
- verification - uppal中简单的基本验证问题
- python-3.x - 'Shift' + 'enter' 仅在突出显示文本行时有效。我如何更改它,所以我不必突出显示?
- bootstrap-4 - 工具提示未在 ng-bootstrap 中显示
- node.js - 如何从 NodeJS 触发 Angular 中的服务
- c++ - 交叉编译错误 Visual Studio C++
- c# - WPF 日期选择器控件以 dd-mm-yyyy 格式保存
- powershell - 将域 A 中的组 A 添加为域 B 中组 B 的成员需要哪些 powershell 命令?
- c# - 如果不处置 HttpContext.Current.Items 会发生什么?
- jquery - 压缩此代码的最佳方法是什么?它是功能性的,但不是很干燥