<i id='dKj1W'><tr id='dKj1W'><dt id='dKj1W'><q id='dKj1W'><span id='dKj1W'><b id='dKj1W'><form id='dKj1W'><ins id='dKj1W'></ins><ul id='dKj1W'></ul><sub id='dKj1W'></sub></form><legend id='dKj1W'></legend><bdo id='dKj1W'><pre id='dKj1W'><center id='dKj1W'></center></pre></bdo></b><th id='dKj1W'></th></span></q></dt></tr></i><div id='dKj1W'><tfoot id='dKj1W'></tfoot><dl id='dKj1W'><fieldset id='dKj1W'></fieldset></dl></div>
    1. <legend id='dKj1W'><style id='dKj1W'><dir id='dKj1W'><q id='dKj1W'></q></dir></style></legend>
        <bdo id='dKj1W'></bdo><ul id='dKj1W'></ul>

        <small id='dKj1W'></small><noframes id='dKj1W'>

        <tfoot id='dKj1W'></tfoot>

      1. 为什么“返回 list.sort()"?返回无,而不是列表?

        时间:2023-09-02

          • <tfoot id='45xBP'></tfoot>

            • <i id='45xBP'><tr id='45xBP'><dt id='45xBP'><q id='45xBP'><span id='45xBP'><b id='45xBP'><form id='45xBP'><ins id='45xBP'></ins><ul id='45xBP'></ul><sub id='45xBP'></sub></form><legend id='45xBP'></legend><bdo id='45xBP'><pre id='45xBP'><center id='45xBP'></center></pre></bdo></b><th id='45xBP'></th></span></q></dt></tr></i><div id='45xBP'><tfoot id='45xBP'></tfoot><dl id='45xBP'><fieldset id='45xBP'></fieldset></dl></div>

              <small id='45xBP'></small><noframes id='45xBP'>

              1. <legend id='45xBP'><style id='45xBP'><dir id='45xBP'><q id='45xBP'></q></dir></style></legend>
                  <bdo id='45xBP'></bdo><ul id='45xBP'></ul>
                    <tbody id='45xBP'></tbody>
                  本文介绍了为什么“返回 list.sort()"?返回无,而不是列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经能够验证 findUniqueWords 确实会产生一个排序的 list.但是,它不会返回列表.为什么?

                  I've been able to verify that the findUniqueWords does result in a sorted list. However, it does not return the list. Why?

                  def findUniqueWords(theList):
                      newList = []
                      words = []
                  
                      # Read a line at a time
                      for item in theList:
                  
                          # Remove any punctuation from the line
                          cleaned = cleanUp(item)
                  
                          # Split the line into separate words
                          words = cleaned.split()
                  
                          # Evaluate each word
                          for word in words:
                  
                              # Count each unique word
                              if word not in newList:
                                  newList.append(word)
                  
                      answer = newList.sort()
                      return answer
                  

                  推荐答案

                  list.sort 对列表进行就地排序,即不返回新列表.随便写

                  list.sort sorts the list in place, i.e. it doesn't return a new list. Just write

                  newList.sort()
                  return newList
                  

                  这篇关于为什么“返回 list.sort()"?返回无,而不是列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Jinja2 中 url_for() 中的块标记 下一篇:return 语句的目的是什么?它与印刷有何不同?

                  相关文章

                    <tfoot id='74fMH'></tfoot>
                    1. <small id='74fMH'></small><noframes id='74fMH'>

                    2. <i id='74fMH'><tr id='74fMH'><dt id='74fMH'><q id='74fMH'><span id='74fMH'><b id='74fMH'><form id='74fMH'><ins id='74fMH'></ins><ul id='74fMH'></ul><sub id='74fMH'></sub></form><legend id='74fMH'></legend><bdo id='74fMH'><pre id='74fMH'><center id='74fMH'></center></pre></bdo></b><th id='74fMH'></th></span></q></dt></tr></i><div id='74fMH'><tfoot id='74fMH'></tfoot><dl id='74fMH'><fieldset id='74fMH'></fieldset></dl></div>

                      <legend id='74fMH'><style id='74fMH'><dir id='74fMH'><q id='74fMH'></q></dir></style></legend>

                        <bdo id='74fMH'></bdo><ul id='74fMH'></ul>