输出应该是给定输入的前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 ")