如何在for循環期間修改列表條目? - How to modify list entries during for loop?

問題:

Now I know that it is not safe to modify the list during an iterative looping.現在我知道在迭代循環期間修改列表是不安全的。 However, suppose I have a list of strings, and I want to strip the strings themselves.但是,假設我有一個字符串列表,並且我想剝離這些字符串本身。 Does replacement of mutable values count as modification?替換可變值算作修改嗎?


解決方案:

參考一: https://en.stackoom.com/question/H7i5
參考二: https://stackoom.com/question/H7i5
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章