為什么我這個程序不能輸出 ['HELLO','WORLD',101] ?
def toUppers(L):
? ? for a in L:
? ? ? ? if isinstance(a,str):
? ? ? ? ? ? return a.upper()
????????else:
????????????return a
print toUppers(['Hello', 'world', 101])
def toUppers(L):
? ? for a in L:
? ? ? ? if isinstance(a,str):
? ? ? ? ? ? return a.upper()
????????else:
????????????return a
print toUppers(['Hello', 'world', 101])
2019-04-01
舉報
2019-04-01
懂了,我這樣寫的話返回值不是list,遇到第一個元素是str就會結束循環