實現函式 tolowercase(),該函式接收乙個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。
示例 1:
輸入: "hello"示例 2:輸出: "hello"
輸入: "here"示例 3:輸出: "here"
輸入: "lovely"輸出: "lovely"
歡迎批評指正
class solution:def tolowercase(self, str):
""":type str: str
:rtype: str
"""self.s = str
str1 = ''
for each in self.s:
if each.isupper():
str1 += each.lower()
else:
str1 += each
return str1
709 轉換成小寫字母
實現函式 tolowercase 該函式接收乙個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。示例 1 輸入 hello 輸出 hello 示例 2 輸入 here 輸出 here 示例3 輸入 lovely 輸出 lovely 思路 直接使用python自帶的字串方法,...
709 轉換成小寫字母
問題描述 實現函式 tolowercase 該函式接收乙個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串。示例 示例 1 輸入 hello 輸出 hello 示例 2 輸入 here 輸出 here 示例 3 輸入 lovely 輸出 lovely 注意 charat 方法...
演算法 709 轉換成小寫字母
實現函式 tolowercase 該函式接收乙個字串引數 str,並將該字串中的大寫字母轉換成小寫字母,之後返回新的字串 示例 1 輸入 hello 輸出 hello 示例 2 輸入 here 輸出 here 示例 3 輸入 lovely 輸出 lovely 就是 判斷字串每乙個位元組的ascll碼...