使用切片就可以很容易地做到:

>>>
>>> for w in words[:]:  # Loop over a slice copy of the entire list.
...     if len(w) > 6:
...         words.insert(0, w)
...
>>> words
['defenestrate', 'cat', 'window', 'defenestrate']

相关文章:

  • 2021-06-30
  • 2021-09-04
  • 2021-10-07
  • 2022-12-23
  • 2021-10-19
  • 2021-10-12
  • 2021-06-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-01-24
  • 2022-01-11
  • 2021-08-19
相关资源
相似解决方案