python - 获取名为 region_name 的第三个输入,它是一个字符串。将 region_list 中包含的适当字符串附加到您的打印语句中
问题描述
问题是:
上面的assessRent() 函数非常方便。唯一的限制是它会产生通用响应。修改代码以执行以下操作:
1)获取第三个输入,称为 region_name,它是一个字符串
2) 将 region_list 中包含的适当字符串附加到您的打印语句中,以给出与上下文相关的响应
def assessRent(region_list, threshold, region_name):
i = 0
while i < len(region_list):
if region_list[i] < region_name:
if i == 0: # modify the string response below
print("A Bachelor apartment in this region costs " + int(region_list[i]) + " on average, which is affordable")
else: # modify the string response below
print("A " + str(i) + " bedroom apartment in this region costs " + int(region_list[i]) + " on average, which is affordable")
i += 1
错误信息:
TypeError:“int”和“str”的实例之间不支持“<”
解决方案
推荐阅读
- julia - 哪个非线性求解器是为正态分布定义的?
- python - 使用python中的beautifulsoup将文本添加到数组中
- windows - 在 github 操作上使用 MinGW 构建提升
- android - 如何在保持纵横比的同时调整图像大小以适应具有 4 个约束且没有宽度或高度参数的图像视图?
- android - 具有可访问性角色的Android选项卡组件?
- sql-server - 有没有办法将 MS Access 报告和表单转换为任何 Web 应用程序框架?
- java - 在 Android EditText 中,有没有办法强制每个字符都是小写的?
- react-native - 排毒与@react-native-community/async-storage 问题?
- r - 带有 felm (lfe) 回归的三明治标准误差:动态定义公式
- c++11 - 解决方案在预测试 2 中失败