[英]with This below Code i am getting error AttributeError: 'str' object has no attribute 'items' ,
[英]I have a code that has some items and its pricings, i am supposed to print out the words that is below certain price
price = {"table": 120, "chair": 40, "lamp": 14, "bed":250, "mattress": 100, "pillow": 10, "shelf": 70, "sofa": 400}
我试过像
if price <= 100:
print(price)
您需要一个for
循环来检查if
条件然后打印。
prices = {"table": 120, "chair": 40, "lamp": 14, "bed":250, "mattress": 100, "pillow": 10, "shelf": 70, "sofa": 400}
for thing in prices:
if prices[thing] <= 100:
print(thing, prices[thing])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.