0
我試圖通過一個字符串滾動並將每個字符添加到另一個字符串來創建一個新的字符串。通過滾動在Python中創建複製字符串
我有以下功能
def rocConvert(self, s):
newString = ""
for c in s:
if c.isupper():
newString += c
elif c.islower():
newString += c
else:
newString += c
return newString
出於某種原因,這只是返回S的第一個字符。注意,我意識到我的方法對於複製而言有點奇怪:我的結束函數實際上會更改該值,如果它是小寫或大寫字符。
爲什麼這隻返回s的第一個字符?
在這裏工作正常... – kindall
我收到整個輸入字符串作爲返回使用您在Python 2.7.4中不變的代碼控制檯 –
對我來說也適用。 python 2.7.5 – nio