In python, what does len(list) do?

后端 未结 4 1228
耶瑟儿~
耶瑟儿~ 2021-02-19 23:51

Does len(list) calculate the length of the list every time it is called, or does it return the value of the built-in counter?
I have a context where I need to c

4条回答
  •  庸人自扰
    2021-02-20 00:43

    len(list) returns the length of a list. If you change it, you'll have to check it's length every iteration. Or use a counter.

提交回复
热议问题