尝试编写一个代码,允许用户在一个空列表中填写房价,然后通过给一个新的值进行排序。你知道吗
import Utils2
do_again = 'yes'
house_price = []
while do_again == 'yes' :
price =Utils2.get_int('Please enter house price:')
house_price.append(price)
do_again = Utils2.yes_or_no('try another (yes or no)?')
#end while
mid_range_house = []
low_price_house =[]
high_price_house=[]
print('the price of houses is :')
for each in house_price:
if (mid_range_house <=each ):
low_price_house.append(each)
else:
high_price_house.append(each)
您正在将列表与整数进行比较:
其中
mid_range_house
是列表,each
是整数。你知道吗不清楚您试图用代码实现什么,但是您需要将数字与其他数字进行比较仅。你知道吗
如果您想找到中间房价,请对
house_price
列表进行排序,然后选择中间值:相关问题 更多 >
编程相关推荐