輸出應該是給定輸入的前3個字母,但即使在輸入上使用strip函數後,我也無法刪除空白。 代碼: from collections import Counter
insider = input("Enter the input you wanna enter : ")
actual = insider.strip()
count = Counter()
for
這看起來像一個簡單的問題,但不在我的情況。 我有一個列表 list0 = ['amigohello','amigobye']
,我想從中刪除的「朋友」。 如果我嘗試: for x in list0:
print x.split("amigo")
它給了我旁邊: ['', 'hello']
['', 'bye']
我想: for x in list0:
x = st
我在python中創建了一個Hot Dog模擬器,並帶有一個類「HotDog」。 當我格式化字符串,如果有2種調味品,我寫了這個代碼,將其添加到字符串: if len(self.condiments) == 2:
for i in self.condiments:
msg = msg + i + " and "
msg = msg.strip(" and ")