已采納回答 / 慕斯7487938
因為return的原因,for語句只執行了一次。可以將每次的結果存入一個list,讓后return這個list。修改后的代碼如下:def toUppers(L):? ? M=[]? ? for x in L:? ? ? ? if isinstance(x,str):? ? ? ? ? ? m=x.upper()? ? ? ? ? ? M.append(m)? ? return Mprint toUppers(['Hello', 'world', 101])
2018-06-27
已采納回答 / 慕斯卡4456334
?無法一邊遍歷一邊刪除。我是復制了set的內容 達到你程序可以運行的程度,但是答案并不正確:
s?=?set(['Adam',?'Lisa',?'Paul']) d?=?['Adam',?'Lisa',?'Paul'] L?=?['Adam',?'Lisa',?'Bart',?'Paul'] for?x?i...
2018-06-21