![](/img/trans.png)
[英]Trying to add a new last element in a list while using the method insert()
[英]Insert element into a list method
我正在尝试将新项目插入已排序的列表中,然后在列表中的更正(排序)位置输入该项目。 每当我测试我的代码以查看它是否正常工作时,我都会收到一条消息,我并不十分熟悉。 我知道到目前为止我所得到的是不正确的,但是如果我不明白自己所收到的消息,我将看不到我在做错什么。.BTW我不允许使用任何内置列表功能
]
Your answer: <__main__.SortedList object at 0x1681c10>
我到目前为止所拥有的:
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)
在代码中的某些时候,您的讲师提供的包装器代码中可能是一段类似于以下内容的代码:
list_object = SortedList()
print list_object
print list_object
,甚至print SortedList()
都会产生类似的输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.