課程
/后端開發
/Python
/初識Python
雖然輸出成功,字母改為大寫,但是后面的證書被忽略掉了,請問大家有什么思路,可以把101這個數字也顯示出來?
2018-05-16
源自:初識Python 10-3
正在回答
def toUppers(L):
? ? L1 = []
? ? for x in L:
? ? ? ? if isinstance(x, str):
? ? ? ? ? ? L1.append(x.upper())
? ? ? ? else:
? ? ? ? ? ? L1.append(x)
? ? return L1
print toUppers(['Hello', 'world', 101])
或者說,再這種格式中,如何添加一個else條件,如果不是str類型,則不用.upper(),直接返回原值
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-05-18
def toUppers(L):
? ? L1 = []
? ? for x in L:
? ? ? ? if isinstance(x, str):
? ? ? ? ? ? L1.append(x.upper())
? ? ? ? else:
? ? ? ? ? ? L1.append(x)
? ? return L1
print toUppers(['Hello', 'world', 101])
2018-05-16
或者說,再這種格式中,如何添加一個else條件,如果不是str類型,則不用.upper(),直接返回原值