0
我想從一個字符串在Python 3下刪除一個角色是我的代碼:試圖從一個字符串在Python刪除一個3字
#Function that removes a character from a string
def removeChar(character, string):
new_string = string.replace(character, "")
print(removeChar("e", "Hello World"))
不過,這一方案的輸出只是None
。我的代碼有什麼問題?
,因爲你沒有返回'new_string'值... –
加上'在函數的最後返回new_string' – rassar