<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()"?返回无,而不是列表?

        Why does quot;return list.sort()quot; return None, not the list?(为什么“返回 list.sort()?返回无,而不是列表?)

          • <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()"?返回无,而不是列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)

                      <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>
                          <tbody id='74fMH'></tbody>

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

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