Ask coding questions

← Back to all posts
Why am i am not getting name printed ?
KritikaAsreth (0)

like maika,kritika,raman

class Person:
def init(self,name,age):
self.name=name
self.age=age

def lt(self,other):
return self.age<other.age

def str(self):
return str(self.name)

def insertion(people):

for i in range(len(people)):
  j=i

  while j>0 and people[j-1]>people[j]:
    people[j-1],people[j]=people[j],people[j-1]
    j=j-1

if name=='main':
people=[Person('raman',25),Person('kritika',23),Person('maika',1)]
print(people)

Comments
hotnewtop
RYANTADIPARTHI (6006)

Solution

you need to print the actual function. Try this

if __name__=='__main__':
  people=[Person('raman',25),Person('kritika',23),Person('maika',1)]
  insertion(people)
  print(people.__str__)

like that.
That should work

KritikaAsreth (0)

@RYANTADIPARTHI Thank you for taking the time to reply :)because of you I tried again ,but people.str is not solution,what worked is:-
for item in people:
print(item)
thanks again :)