sorted and sort()

有序的列表

https://www.nowcoder.com/practice/855d960ba868480ba6e626914018ded4

str1 = "Python"
my_list = list(str1)
print(sorted(my_list))
print(my_list)
my_list.sort(reverse=True)
print(my_list)

So pay attention to the function sorted :https://www.runoob.com/python/python-func-sorted.html and the Python List sort() :https://www.runoob.com/python/att-list-sort.html

Sort and sorted differences:

Sort is a method applied to List, and Sorted can sort all the iterative objects.

The Sort method of the list returns to operate the existence list without returning values, and the built -in function Sorted method returns a new list, not the operation on the original basis.

全部评论

相关推荐

04-10 11:37
黑河学院 运营
点赞 评论 收藏
分享
04-03 18:59
吉林大学 Java
大专人陈义:别投了,我看到有人点了第二个链接投递,还没退出界面,不合适的邮件就发过来了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务