Repository navigation
修正列表章节中 insert、pop 和 sort 的参数说明 - #324
Open
petergrammy wants to merge 1 commit into
Open
petergrammy wants to merge 1 commit into
petergrammy wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
名单示例的注释把
len(user)-1写成了insert可接受的最大下标。实际上,传入len(user)或更大的下标都会把新用户加到末尾。方法表还把pop的默认参数写成了最后一个元素的值,容易让读者把值当成下标传进去。改动区分了按下标删除的
pop和按值删除的remove,并将sort的排序依据改为 Python 3 支持的关键字参数key。在 Python 3.12.7 中运行了完整名单示例,逐行比对了输出。另外验证了末尾插入、指定下标与默认下标的
pop、重复值与缺失值的remove,以及带key和reverse的排序。改动和验证使用了 OpenAI Codex。