[英]What would be the non-comprehension list way of doing this sum
def nested_sum(L):
return sum( nested_sum(x) if isinstance(x, list) else x for x in L )
這是Eugenie在以下文章中提供的解決方案: Python中嵌套列表的總和
我只是試圖在不使用理解列表的情況下重新創建它,但是我無法獲得它。 我該怎么辦?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.