According to the given housing information, Python is used to output the source information of the three houses with the lowest listing price and the source information of the three houses with the most popular prices.
code show as below:
dict_house={
'001':["3室1厅",68.69,"南北","简装",37124,35],
'002':["2室2厅",87.16,"南西","精装",37375,148],
'003':["3室1厅",61.72,"南北","精装",37266,146],
'004':["3室2厅",68.18,"南北","精装",68496,79],
'005':["2室2厅",71.67,"南","简装",33487,105],
'006':["3室1厅",84.78,"南北","简装",51782,34]}
list_s=[]
for i,j in dict_house.items():
T=list(j)
T.insert(0,i)
list_s.append(list(T))
T.clear()
list_s.sort(key=lambda x:x[5])
print("挂牌价最低的三套房源信息:")
for i in range(0,3):
s=[str(x) for x in list_s[i]]
print(" ".join(s))
del s
list_s.sort(key=lambda x:x[6])
print("人气最高的三套房源信息:")
for i in range(-1,-4,-1):
s=[str(x) for x in list_s[i]]
print(" ".join(s))
del s
The results are as follows:
Caicai's code, I hope it can help you!