為什么返回結果里多出來一個None
def toUppers(L):
? ? for x in L:
if isinstance(x,str):
print(x.upper())
print toUppers(['Hello', 'world', 101])
def toUppers(L):
? ? for x in L:
if isinstance(x,str):
print(x.upper())
print toUppers(['Hello', 'world', 101])
2018-07-29
舉報
2018-08-16
你這toUppers逐個取L中的各個元素,如果是字符就全變成大寫,否則返回None,所以101返回了None,被打印出來了
2018-07-29
toUppers(L沒有返回值,所以最后一句print toUppers(['Hello', 'world', 101])相當于print None