0

I'm trying to print a list of objects, but it prints as [<__main__.Hi object at 0x7f28482b0f70>, <__main__.Hi object at 0x7f132d0cc790>]. I want to print it as ["Hello", "Hi"]. How would I do this?

class Hi:
  def __init__(self, greeting, number):
    self.greeting=greeting
    self.number=number

  def hello(self):
    print("Hi I am", self.greeting)


  

x=[Hi("Hello",20), Hi("Hi",30)]
print(x)
martineau
  • 119,623
  • 25
  • 170
  • 301
John Lee
  • 1
  • 1

0 Answers0