0
class Mobile:
    def __init__(self,brand,price):
        self.brand = brand
        self.price = price

mob1=Mobile("Apple", 1000)
mob2=Mobile("Samsung", 5000)
mob3=Mobile("Apple", 3000)

mob_dict = {
          "m1":mob1,
          "m2":mob2,
          "m3":mob3
          }

lit = []

for key,value in mob_dict.items():
    if value.price > 3000:
        lit.append(value)
        print (value.brand,value.price)
print(lit)

Output:

[<__main__.Mobile object at 0x000001C45C721100>]

Please explain why am getting this output.

khelwood
  • 55,782
  • 14
  • 81
  • 108

1 Answers1

0

You are printing the whole object, you can do print(lit[0]) or:

for elem in lit:
    print(elem)