I’m trying to insert a new item into a sorted list, entering the item in the corrected (Sorted) position in the list. Everytime i test my code to see if it’s working or not though, i’m getting a message that i’m not really familiar with. i know what i have so far isn’t correct, but i’m not able to see what i’m doing wrong if i don’t understand the message that i’m getting..
BTW i’m not allowed to use any built-in list functions
]
Your answer: <__main__.SortedList object at 0x1681c10>
What i have so far:
class SortedList:
def __init__(self):
self.L = []
def insert(self, item):
data= []
for j in range(len(self.L)):
data.append(self.L[j])
return (data)
Looks like the problem is just that your
SortedListclass isn’t defining a way to print it. Try adding:See this for a discussion of special methods.